Files
trivy/cache/cache_test.go
2019-12-16 08:44:43 +02:00

23 lines
454 B
Go

package cache
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRealCache_Clear(t *testing.T) {
d, _ := ioutil.TempDir("", "TestRealCache_Clear")
c := Initialize(d)
assert.NoError(t, c.Clear())
_, err := os.Stat(d)
assert.True(t, os.IsNotExist(err))
t.Run("sad path, cache dir doesn't exist", func(t *testing.T) {
c := Initialize(".")
assert.Equal(t, "failed to remove cache", c.Clear().Error())
})
}