| 1 | package sidecar |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "errors" |
| 6 | "testing" |
| 7 | |
| 8 | "reasonix/internal/pluginpkg" |
| 9 | ) |
| 10 | |
| 11 | // TestNthRequiredFailureClosesEarlierSuccesses: Nth required fail → nil manager. |
| 12 | func TestNthRequiredFailureClosesEarlierSuccesses(t *testing.T) { |
| 13 | home := t.TempDir() |
| 14 | installFakePlugin(t, home, "p1", func(rt *pluginpkg.RuntimeSpec) { rt.Required = true }) |
| 15 | installFakePlugin(t, home, "p2", func(rt *pluginpkg.RuntimeSpec) { rt.Required = true }) |
| 16 | installFakePlugin(t, home, "p3-bad", func(rt *pluginpkg.RuntimeSpec) { |
| 17 | rt.Required = true |
| 18 | rt.Env[fakeEnvInitResult] = `{"protocolVersion":"1","name":"bad","version":"1","stateSchemaVersion":0}` |
| 19 | }) |
| 20 | mgr, _, err := StartPackages(context.Background(), home, testSessionContext(), nil) |
| 21 | if err == nil { |
| 22 | t.Fatal("expected required failure") |
| 23 | } |
| 24 | var req *RequiredStartError |
| 25 | if !errors.As(err, &req) { |
| 26 | t.Fatalf("err = %T %v", err, err) |
| 27 | } |
| 28 | if mgr != nil { |
| 29 | t.Fatal("manager must be nil after required failure (all closed)") |
| 30 | } |
| 31 | } |
| 32 |