Download this file
| 1 | package hostfloor |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestParticipationPreservesFloorAndLegacyDirectoryRules(t *testing.T) { |
| 10 | t.Setenv("CARLOS_HOST_CLAIM", "") |
| 11 | d := Disk{Participation: floorParticipationFixture(t)} |
| 12 | if err := d.Participation.State.Remove("census.json"); err != nil { |
| 13 | t.Fatal(err) |
| 14 | } |
| 15 | data := t.TempDir() |
| 16 | if err := d.CheckParticipation(t.Context(), data, false); err != nil { |
| 17 | t.Fatal(err) |
| 18 | } |
| 19 | if err := d.ControllersIdle(t.Context(), data); err == nil { |
| 20 | t.Fatal("floor accepted a missing controller directory") |
| 21 | } |
| 22 | if err := os.Symlink(t.TempDir(), filepath.Join(data, ".hostexec")); err != nil { |
| 23 | t.Skip(err) |
| 24 | } |
| 25 | for _, strict := range []bool{false, true} { |
| 26 | if err := d.CheckParticipation(t.Context(), data, strict); err == nil { |
| 27 | t.Fatalf("symlink accepted with requireDirectory=%v", strict) |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |