Skip to content

Commit 859e15a

Browse files
committed
add test for osv-scan parser not erroring when receiving an empty file
1 parent 4a0deee commit 859e15a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

components/scanners/osv-scanner/internal/transformer/testdata/empty.json

Whitespace-only changes.

components/scanners/osv-scanner/internal/transformer/transformer_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ func TestTransformer_Transform(t *testing.T) {
4141
transformMethodTest(t, ocsfTransformer.Transform, nil, 11)
4242
})
4343
t.Run("it should exit cleanly when there are no results", func(t *testing.T) {
44-
path, err := os.Getwd()
45-
require.NoError(t, err)
46-
os.Setenv("RAW_OUT_FILE", "./testdata/empty.json")
44+
45+
path := filepath.Join(t.TempDir(), "empty.sarif.json")
46+
require.NoError(t, os.WriteFile(path, []byte("{}"), 0644))
47+
os.Setenv("RAW_OUT_FILE", path)
48+
4749
ocsfTransformer, err := New(
4850
OSVScannerTransformerWithClock(clock),
4951
OSVScannerTransformerWithProjectRoot(filepath.Join(path, ".")),

0 commit comments

Comments
 (0)