| 24 | } |
| 25 | |
| 26 | func TestLicense(t *testing.T) { |
| 27 | testCases := []struct { |
| 28 | Description string |
| 29 | Path string |
| 30 | Analyzer *analysis.Analyzer |
| 31 | }{ |
| 32 | { |
| 33 | "Standard", |
| 34 | "standard", |
| 35 | license.Analyzer, |
| 36 | }, |
| 37 | { |
| 38 | "Enterprise", |
| 39 | "enterprise", |
| 40 | license.EEAnalyzer, |
| 41 | }, |
| 42 | { |
| 43 | "Source Available", |
| 44 | "source_available/enterprise", |
| 45 | license.Analyzer, |
| 46 | }, |
| 47 | } |
| 48 | |
| 49 | for _, testCase := range testCases { |
| 50 | t.Run(testCase.Description, func(t *testing.T) { |
| 51 | t.Run("ignored", func(t *testing.T) { |
| 52 | t.Run("specified file", func(t *testing.T) { |
| 53 | testdata := analysistest.TestData() |
| 54 | require.NoError(t, testCase.Analyzer.Flags.Set("ignore", "ignored1.go,ignored2.go")) |
| 55 | t.Cleanup(func() { |
| 56 | require.NoError(t, testCase.Analyzer.Flags.Set("ignore", "")) |
| 57 | }) |
| 58 | |
| 59 | analysistest.Run(t, testdata, testCase.Analyzer, filepath.Join(testCase.Path, "ignored_files")) |
| 60 | }) |
| 61 | |
| 62 | t.Run("mockery", func(t *testing.T) { |
| 63 | testdata := analysistest.TestData() |
| 64 | analysistest.Run(t, testdata, testCase.Analyzer, filepath.Join(testCase.Path, "ignored/mockery")) |
| 65 | }) |
| 66 | |
| 67 | t.Run("mockgen", func(t *testing.T) { |
| 68 | testdata := analysistest.TestData() |
| 69 | analysistest.Run(t, testdata, testCase.Analyzer, filepath.Join(testCase.Path, "ignored/mockgen")) |
| 70 | }) |
| 71 | |
| 72 | t.Run("go-bindata", func(t *testing.T) { |
| 73 | testdata := analysistest.TestData() |
| 74 | analysistest.Run(t, testdata, testCase.Analyzer, filepath.Join(testCase.Path, "ignored/go-bin-data")) |
| 75 | }) |
| 76 | |
| 77 | t.Run("manifest", func(t *testing.T) { |
| 78 | testdata := analysistest.TestData() |
| 79 | analysistest.Run(t, testdata, testCase.Analyzer, filepath.Join(testCase.Path, "ignored/manifest")) |
| 80 | }) |
| 81 | }) |
| 82 | |
| 83 | t.Run("missing license", func(t *testing.T) { |