Skip to content

Commit

Permalink
add unit tests for adding files to a denied stating directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomanski committed Sep 17, 2022
1 parent 85afb8b commit 740d005
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions image_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,15 @@ func TestWriterAddLocalDirectoryWithFile(t *testing.T) {

assert.False(t, os.IsNotExist(err))
}

func TestWriter_DeniedStagingDir(t *testing.T) {
w := &ImageWriter{stagingDir: "/usr/access_denied"}

err := w.AddLocalFile("/etc/hosts", "foo")
assert.Error(t, err)
assert.True(t, os.IsPermission(err), "err should have been a permission denied directory, but is: %+v", err)

err = w.AddFile(strings.NewReader("somestring"), "foo")
assert.Error(t, err)
assert.True(t, os.IsPermission(err), "err should have been a permission denied directory, but is: %+v", err)
}

0 comments on commit 740d005

Please sign in to comment.