@@ -26,6 +26,10 @@ func safetyTestRepo(t *testing.T) string {
2626
2727func 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+
5368func writeValidSavedFeaturePlan (t * testing.T , repo , feature string ) string {
5469 t .Helper ()
5570 directory := filepath .Join (repo , ".product-loop" , "features" , feature )
0 commit comments