Skip to content

Commit

Permalink
add correct test of implicit .resource_types purge prevention
Browse files Browse the repository at this point in the history
  • Loading branch information
xorpaul committed May 25, 2022
1 parent 1ed327b commit bfa570f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion g10k_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,11 @@ func TestPurgeStaleContent(t *testing.T) {
defer f.Close()
f.WriteString("foobar")
f.Sync()
createOrPurgeDir("/tmp/example/single/.resource_types", funcName)
r, _ := os.Create("/tmp/example/single/.resource_types/test.pp")
defer r.Close()
r.WriteString("foobar")
r.Sync()

cmd := exec.Command(os.Args[0], "-test.run="+funcName+"$")
cmd.Env = append(os.Environ(), "TEST_FOR_CRASH_"+funcName+"=1")
Expand All @@ -2231,7 +2236,7 @@ func TestPurgeStaleContent(t *testing.T) {
if expectedExitCode != exitCode {
t.Errorf("terminated with %v, but we expected exit status %v", exitCode, expectedExitCode)
}
//fmt.Println(string(out))
// fmt.Println(string(out))

expectedLines := []string{
"DEBUG checkForStaleContent(): filepath.Walk'ing directory /tmp/example/single",
Expand Down Expand Up @@ -2259,6 +2264,10 @@ func TestPurgeStaleContent(t *testing.T) {
t.Errorf("Missing module file that should be there")
}

if !fileExists("/tmp/example/single/.resource_types/test.pp") {
t.Errorf("Missing resource_types file /tmp/example/single/.resource_types/test.pp that should be there")
}

purgeDir(cacheDir, funcName)
purgeDir("/tmp/example", funcName)
}
Expand Down

0 comments on commit bfa570f

Please sign in to comment.