Skip to content

Commit

Permalink
i/statemachine: Improve TestClassicMachine_manualMakeDirs_fail robust…
Browse files Browse the repository at this point in the history
…ness

Signed-off-by: Paul Mars <paul.mars@canonical.com>
  • Loading branch information
upils committed Oct 16, 2024
1 parent d4a21d7 commit 50a80c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/statemachine/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,11 +720,15 @@ func TestClassicMachine_manualMakeDirs_fail(t *testing.T) {
},
}

tmpDir, err := os.MkdirTemp("/tmp", "ubuntu-image-")
asserter.AssertErrNil(err, true)
t.Cleanup(func() { os.RemoveAll(tmpDir) })

// Create a file where we will then try to create a directory
_, err := osCreate("/tmp/test")
_, err = osCreate(filepath.Join(tmpDir, "test"))
asserter.AssertErrNil(err, true)

err = manualMakeDirs(mkdirs, "/tmp", true)
err = manualMakeDirs(mkdirs, tmpDir, true)
asserter.AssertErrContains(err, "Error creating directory")
}

Expand Down

0 comments on commit 50a80c6

Please sign in to comment.