Skip to content

Commit 49cc439

Browse files
committed
test: bind guard fixtures to current branch
1 parent b664f7a commit 49cc439

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

boatstack/safety_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ func safetyTestRepo(t *testing.T) string {
2626

2727
func engageHookFixture(t *testing.T, repo string) {
2828
t.Helper()
29+
branch := strings.TrimSpace(gitOutput(repo, "branch", "--show-current"))
30+
if branch == "" {
31+
t.Fatal("hook fixture repository has no current branch")
32+
}
2933
lockPath := filepath.Join(WorkspaceFor(repo).FeatureDir("hook-fixture"), "plan.lock.json")
3034
if err := os.MkdirAll(filepath.Dir(lockPath), 0o755); err != nil {
3135
t.Fatal(err)
@@ -39,7 +43,7 @@ func engageHookFixture(t *testing.T, repo string) {
3943
}
4044
state := DeliveryState{
4145
SchemaVersion: deliveryStateSchemaVersion, Feature: "hook-fixture", PlanLockHash: lockHash,
42-
ActiveIndex: 0, Slices: []DeliverySlice{{ID: "delivery", Status: StatusBuild, BaseBranch: "main", HeadBranch: "main"}},
46+
ActiveIndex: 0, Slices: []DeliverySlice{{ID: "delivery", Status: StatusBuild, BaseBranch: branch, HeadBranch: branch}},
4347
Mode: "NORMAL", RepairCounters: map[string]int{},
4448
}
4549
if err := saveDeliveryState(repo, state); err != nil {
@@ -50,6 +54,17 @@ func engageHookFixture(t *testing.T, repo string) {
5054
}
5155
}
5256

57+
func TestEngageHookFixtureBindsCurrentNonMainBranch(t *testing.T) {
58+
repo := safetyTestRepo(t)
59+
runGit(t, repo, "switch", "-c", "fixture-topic")
60+
engageHookFixture(t, repo)
61+
62+
status := ResolveEngagement(repo, EngagementRequest{})
63+
if status.Mode != EngagementActive || status.Branch != "fixture-topic" {
64+
t.Fatalf("non-main hook fixture engagement = %+v, want ACTIVE on fixture-topic", status)
65+
}
66+
}
67+
5368
func writeValidSavedFeaturePlan(t *testing.T, repo, feature string) string {
5469
t.Helper()
5570
directory := filepath.Join(repo, ".product-loop", "features", feature)

0 commit comments

Comments
 (0)