Download this file
| 1 | package provider |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestClaudeLiveCleanupMarker(t *testing.T) { |
| 10 | l := claudeRuntimeFixture(t) |
| 11 | path := filepath.Join(l.runtime, ".last-cleanup") |
| 12 | if err := os.WriteFile(path, make([]byte, 24), 0664); err != nil { |
| 13 | t.Fatal(err) |
| 14 | } |
| 15 | if err := l.validateRuntimeEntries(); err != nil { |
| 16 | t.Fatalf("observed marker rejected: %v", err) |
| 17 | } |
| 18 | for _, tc := range []struct { |
| 19 | name string |
| 20 | size int |
| 21 | }{{".last-cleanup", 25}, {".last-cleanup.extra", 24}} { |
| 22 | os.Remove(path) |
| 23 | p := filepath.Join(l.runtime, tc.name) |
| 24 | os.WriteFile(p, make([]byte, tc.size), 0600) |
| 25 | if l.validateRuntimeEntries() == nil { |
| 26 | t.Fatal("unobserved marker accepted", tc) |
| 27 | } |
| 28 | os.Remove(p) |
| 29 | } |
| 30 | os.Mkdir(path, 0700) |
| 31 | if l.validateRuntimeEntries() == nil { |
| 32 | t.Fatal("marker directory accepted") |
| 33 | } |
| 34 | os.Remove(path) |
| 35 | os.WriteFile(path, make([]byte, 24), 0600) |
| 36 | l.source.Expected.ProviderVersion = "other" |
| 37 | if l.validateRuntimeEntries() == nil { |
| 38 | t.Fatal("other version accepted") |
| 39 | } |
| 40 | } |
| 41 | |