25 lines
1.0 KiB
Go
25 lines
1.0 KiB
Go
package libraryfreeze
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestFreezePreflightRejectsWithoutStoppingAndReplaySkipsIt(t *testing.T) {
|
|
_, c, e := freezeFixture(t)
|
|
_, err := e.RunPrepared(context.Background(), "prepared", func(context.Context) error { return errors.New("tasks active") }, func(context.Context) (string, error) { t.Fatal("capture before ready"); return "", nil })
|
|
if err == nil || len(c.calls) != 0 {
|
|
t.Fatal("preflight did not protect services")
|
|
}
|
|
r, err := e.RunPrepared(context.Background(), "prepared", func(context.Context) error { return nil }, func(context.Context) (string, error) { return strings.Repeat("a", 64), nil })
|
|
if err != nil || r.State != "succeeded" {
|
|
t.Fatalf("ready capture: %+v %v", r, err)
|
|
}
|
|
_, err = e.RunPrepared(context.Background(), "prepared", func(context.Context) error { t.Fatal("completed job consulted changing source"); return nil }, func(context.Context) (string, error) { t.Fatal("completed job captured again"); return "", nil })
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|