aboutsummaryrefslogtreecommitdiff
path: root/spdxconv_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-01-15 20:10:24 +0700
committerShulhan <ms@kilabit.info>2026-01-15 20:10:24 +0700
commit32e4ea9ddf0c2d37f00fa81a4fb1dfe67420b8fe (patch)
treedfd48a62d0fbd6ad8701cb86f487324d034a4ae7 /spdxconv_test.go
parent735a82afd34af67cc3aa7e3ea84b766e25d6df84 (diff)
downloadspdxconv-32e4ea9ddf0c2d37f00fa81a4fb1dfe67420b8fe.tar.xz
all: add test for Scan on new file without git history
New file without git history should use the year from configuration.
Diffstat (limited to 'spdxconv_test.go')
-rw-r--r--spdxconv_test.go61
1 files changed, 3 insertions, 58 deletions
diff --git a/spdxconv_test.go b/spdxconv_test.go
index fe8ad1c..1496e14 100644
--- a/spdxconv_test.go
+++ b/spdxconv_test.go
@@ -140,6 +140,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)
- })
- }
-}