Download this file
| 1 | //go:build linux |
| 2 | |
| 3 | package host |
| 4 | |
| 5 | import ( |
| 6 | "os" |
| 7 | "testing" |
| 8 | ) |
| 9 | |
| 10 | // Task 10b: the box's claim assembly is where its Reconciler is built |
| 11 | // (OpenProductionClaimAssembly, whose adapter ClaimAssembly.Build copies). |
| 12 | // It sets FenceClosed and HoldRow with CARLOS_REGION_HA on, and neither |
| 13 | // with it off, so reconcile there is main's. |
| 14 | func TestProductionClaimAssemblySetsTheSourceHoldOnlyWithRegionHA(t *testing.T) { |
| 15 | fixtureWithoutRootMigrationCensus(t) |
| 16 | for _, v := range []string{"", "0", "1"} { |
| 17 | on := v == "1" |
| 18 | t.Run("CARLOS_REGION_HA="+v, func(t *testing.T) { |
| 19 | t.Setenv("CARLOS_REGION_HA", v) |
| 20 | store, resources, owners, legacy := fix4JournalFixture(t) |
| 21 | if err := os.Remove(legacy); err != nil { |
| 22 | t.Fatal(err) |
| 23 | } |
| 24 | assembly, err := OpenProductionClaimAssembly(t.Context(), store, resources, owners) |
| 25 | if err != nil { |
| 26 | t.Fatal(err) |
| 27 | } |
| 28 | defer assembly.Close(t.Context()) |
| 29 | r := assembly.Reconcile.Reconciler |
| 30 | if (r.FenceClosed != nil) != on || (r.HoldRow != nil) != on { |
| 31 | t.Fatalf("CARLOS_REGION_HA=%q: FenceClosed set %v, HoldRow set %v", v, r.FenceClosed != nil, r.HoldRow != nil) |
| 32 | } |
| 33 | }) |
| 34 | } |
| 35 | } |
| 36 | |