| 1 | package control |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestLoadInactiveLegacyGoalDoesNotWriteOrActivate(t *testing.T) { |
| 10 | c, _, _ := goalRuntimeController(t, &scriptedTurns{}, nil) |
| 11 | path := filepath.Join(t.TempDir(), "goal.json") |
| 12 | c.goals.statePath = path |
| 13 | c.LoadInactiveGoal("legacy metadata objective") |
| 14 | if c.Goal() != "legacy metadata objective" || c.goals.active() { |
| 15 | t.Fatal("legacy objective was dropped or activated") |
| 16 | } |
| 17 | if _, err := os.Stat(path); !os.IsNotExist(err) { |
| 18 | t.Fatalf("read-only load wrote a sidecar: %v", err) |
| 19 | } |
| 20 | scope := c.goals.scopeID |
| 21 | c.SetGoal("legacy metadata objective") |
| 22 | if !c.goals.active() || c.goals.scopeID != scope { |
| 23 | t.Fatal("explicit start did not preserve and activate restored objective") |
| 24 | } |
| 25 | } |
| 26 |