From 32e4ea9ddf0c2d37f00fa81a4fb1dfe67420b8fe Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 15 Jan 2026 20:10:24 +0700 Subject: all: add test for Scan on new file without git history New file without git history should use the year from configuration. --- spdxconv_test.go | 61 +++----------------------------------------------------- 1 file changed, 3 insertions(+), 58 deletions(-) (limited to 'spdxconv_test.go') diff --git a/spdxconv_test.go b/spdxconv_test.go index fe8ad1c..1496e14 100644 --- a/spdxconv_test.go +++ b/spdxconv_test.go @@ -139,6 +139,9 @@ func TestScan(t *testing.T) { }{{ dir: `testdata/scan/`, expReport: string(testData.Output[`scan/spdxconv.report`]), + }, { + dir: `testdata/scan_no_scm/`, + expReport: string(testData.Output[`scan_no_scm/spdxconv.report`]), }, { dir: `testdata/Scan_noConfigAndReport/`, expReport: string(testData.Output[`Scan_noConfigAndReport/spdxconv.report`]), @@ -334,61 +337,3 @@ func TestSPDXConv_scanFile(t *testing.T) { test.Assert(t, tc.dir+"/"+tc.name, tc.exp, got) } } - -func TestSPDXConv_scanDir(t *testing.T) { - type testCase struct { - dir string - exp []string - } - var listCase = []testCase{{ - dir: `testdata/scan/`, - exp: []string{ - `.gitignore`, - `Makefile`, - `a/b/.gitignore`, - `go.mod`, - `go.sum`, - `no_copyright_year.md`, - `po/included.go`, - `po/test.po`, - `po/test.pot`, - `test.go`, - `test.html`, - `test.json`, - `test.sh`, - `test.sql`, - `with_spdx.go`, - }, - }, { - dir: `testdata/scan_no_scm/`, - exp: []string{ - `test.go`, - `test.html`, - `test.sh`, - }, - }} - var tc testCase - var conv *SPDXConv - var err error - var got []string - for _, tc = range listCase { - t.Run(tc.dir, func(tt *testing.T) { - tt.Chdir(tc.dir) - - conv, err = New(`.`) - if err != nil { - tt.Fatal(err) - } - err = conv.prepareScan() - if err != nil { - t.Fatal(err) - } - - got, err = conv.scanDir([]string{`.`}) - if err != nil { - tt.Fatal(err) - } - test.Assert(tt, tc.dir, tc.exp, got) - }) - } -} -- cgit v1.3