diff options
Diffstat (limited to 'pkg/runner/action_cache_test.go')
-rw-r--r-- | pkg/runner/action_cache_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/runner/action_cache_test.go b/pkg/runner/action_cache_test.go new file mode 100644 index 0000000..e222cfb --- /dev/null +++ b/pkg/runner/action_cache_test.go @@ -0,0 +1,37 @@ +package runner + +import ( + "archive/tar" + "bytes" + "context" + "io" + "os" + "testing" + + "github.com/stretchr/testify/assert" +) + +//nolint:gosec +func TestActionCache(t *testing.T) { + a := assert.New(t) + cache := &GoGitActionCache{ + Path: os.TempDir(), + } + ctx := context.Background() + sha, err := cache.Fetch(ctx, "christopherhx/script", "https://github.com/christopherhx/script", "main", "") + a.NoError(err) + a.NotEmpty(sha) + atar, err := cache.GetTarArchive(ctx, "christopherhx/script", sha, "node_modules") + a.NoError(err) + a.NotEmpty(atar) + mytar := tar.NewReader(atar) + th, err := mytar.Next() + a.NoError(err) + a.NotEqual(0, th.Size) + buf := &bytes.Buffer{} + // G110: Potential DoS vulnerability via decompression bomb (gosec) + _, err = io.Copy(buf, mytar) + a.NoError(err) + str := buf.String() + a.NotEmpty(str) +} |