From 9a2bbda2233430ba834c5e7d79f22c573bec1262 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Mon, 14 Jul 2025 01:48:39 +0300 Subject: [PATCH] test: fix linter package names (#23) * test: fix linter package names * chore: pr-lint.yml --- .github/workflows/pr-lint.yml | 4 ---- config/config_test.go | 9 +++++---- fileproc/collector_test.go | 8 +++++--- fileproc/processor_test.go | 8 +++++--- fileproc/walker_test.go | 9 +++++---- fileproc/writer_test.go | 15 ++++++++------- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml index 6f6a6e7..804af4e 100644 --- a/.github/workflows/pr-lint.yml +++ b/.github/workflows/pr-lint.yml @@ -11,10 +11,6 @@ on: permissions: read-all -env: - TRIVY_SEVERITY: CRITICAL,HIGH - DISABLE_LINTERS: GO_GOLANGCI_LINT - jobs: Linter: name: PR Lint diff --git a/config/config_test.go b/config/config_test.go index 8a25cea..a0b7c8e 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1,10 +1,11 @@ -package config +package config_test import ( "os" "path/filepath" "testing" + configpkg "github.com/ivuorinen/gibidify/config" "github.com/spf13/viper" ) @@ -26,15 +27,15 @@ func TestDefaultConfig(t *testing.T) { originalConfigPaths := viper.ConfigFileUsed() viper.Reset() viper.AddConfigPath(tmpDir) - LoadConfig() + configpkg.LoadConfig() // Check defaults - defaultSizeLimit := GetFileSizeLimit() + defaultSizeLimit := configpkg.GetFileSizeLimit() if defaultSizeLimit != 5242880 { t.Errorf("Expected default file size limit of 5242880, got %d", defaultSizeLimit) } - ignoredDirs := GetIgnoredDirectories() + ignoredDirs := configpkg.GetIgnoredDirectories() if len(ignoredDirs) == 0 { t.Errorf("Expected some default ignored directories, got none") } diff --git a/fileproc/collector_test.go b/fileproc/collector_test.go index ef29f50..2437403 100644 --- a/fileproc/collector_test.go +++ b/fileproc/collector_test.go @@ -1,8 +1,10 @@ -package fileproc +package fileproc_test import ( "os" "testing" + + fileproc "github.com/ivuorinen/gibidify/fileproc" ) func TestCollectFilesWithFakeWalker(t *testing.T) { @@ -11,7 +13,7 @@ func TestCollectFilesWithFakeWalker(t *testing.T) { "/path/to/file1.txt", "/path/to/file2.go", } - fake := FakeWalker{ + fake := fileproc.FakeWalker{ Files: expectedFiles, Err: nil, } @@ -35,7 +37,7 @@ func TestCollectFilesWithFakeWalker(t *testing.T) { func TestCollectFilesError(t *testing.T) { // Fake walker returns an error. - fake := FakeWalker{ + fake := fileproc.FakeWalker{ Files: nil, Err: os.ErrNotExist, } diff --git a/fileproc/processor_test.go b/fileproc/processor_test.go index 057e424..d1c1077 100644 --- a/fileproc/processor_test.go +++ b/fileproc/processor_test.go @@ -1,10 +1,12 @@ -package fileproc +package fileproc_test import ( "os" "strings" "sync" "testing" + + fileproc "github.com/ivuorinen/gibidify/fileproc" ) func TestProcessFile(t *testing.T) { @@ -30,12 +32,12 @@ func TestProcessFile(t *testing.T) { return } - ch := make(chan WriteRequest, 1) + ch := make(chan fileproc.WriteRequest, 1) var wg sync.WaitGroup wg.Add(1) go func() { defer wg.Done() - ProcessFile(tmpFile.Name(), ch, "") + fileproc.ProcessFile(tmpFile.Name(), ch, "") }() wg.Wait() close(ch) diff --git a/fileproc/walker_test.go b/fileproc/walker_test.go index b8fb56d..f684947 100644 --- a/fileproc/walker_test.go +++ b/fileproc/walker_test.go @@ -1,4 +1,4 @@ -package fileproc +package fileproc_test import ( "os" @@ -6,6 +6,7 @@ import ( "testing" "github.com/ivuorinen/gibidify/config" + fileproc "github.com/ivuorinen/gibidify/fileproc" "github.com/spf13/viper" ) @@ -53,7 +54,7 @@ func TestProdWalkerWithIgnore(t *testing.T) { viper.Set("ignoreDirectories", []string{"vendor"}) // Run walker - var w Walker = ProdWalker{} + var w fileproc.Walker = fileproc.ProdWalker{} found, err := w.Walk(rootDir) if err != nil { t.Fatalf("Walk returned error: %v", err) @@ -96,7 +97,7 @@ func TestProdWalkerBinaryCheck(t *testing.T) { config.LoadConfig() // Run walker - var w Walker = ProdWalker{} + var w fileproc.Walker = fileproc.ProdWalker{} found, err := w.Walk(rootDir) if err != nil { t.Fatalf("Walk returned error: %v", err) @@ -139,7 +140,7 @@ func TestProdWalkerSizeLimit(t *testing.T) { viper.Reset() config.LoadConfig() - var w Walker = ProdWalker{} + var w fileproc.Walker = fileproc.ProdWalker{} found, err := w.Walk(rootDir) if err != nil { t.Fatalf("Walk returned error: %v", err) diff --git a/fileproc/writer_test.go b/fileproc/writer_test.go index 5c7a2a2..2c3eaa4 100644 --- a/fileproc/writer_test.go +++ b/fileproc/writer_test.go @@ -1,4 +1,4 @@ -package fileproc +package fileproc_test import ( "encoding/json" @@ -7,6 +7,7 @@ import ( "sync" "testing" + fileproc "github.com/ivuorinen/gibidify/fileproc" "gopkg.in/yaml.v3" ) @@ -55,12 +56,12 @@ func TestStartWriter_Formats(t *testing.T) { }() // Prepare channels - writeCh := make(chan WriteRequest, 2) + writeCh := make(chan fileproc.WriteRequest, 2) doneCh := make(chan struct{}) // Write a couple of sample requests - writeCh <- WriteRequest{Path: "sample.go", Content: "package main"} - writeCh <- WriteRequest{Path: "example.py", Content: "def foo(): pass"} + writeCh <- fileproc.WriteRequest{Path: "sample.go", Content: "package main"} + writeCh <- fileproc.WriteRequest{Path: "example.py", Content: "def foo(): pass"} close(writeCh) // Start the writer @@ -68,7 +69,7 @@ func TestStartWriter_Formats(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - StartWriter(outFile, writeCh, doneCh, tc.format, "PREFIX", "SUFFIX") + fileproc.StartWriter(outFile, writeCh, doneCh, tc.format, "PREFIX", "SUFFIX") }() // Wait until writer signals completion @@ -94,12 +95,12 @@ func TestStartWriter_Formats(t *testing.T) { switch tc.format { case "json": // Quick parse check - var outStruct OutputData + var outStruct fileproc.OutputData if err := json.Unmarshal(data, &outStruct); err != nil { t.Errorf("JSON unmarshal failed: %v", err) } case "yaml": - var outStruct OutputData + var outStruct fileproc.OutputData if err := yaml.Unmarshal(data, &outStruct); err != nil { t.Errorf("YAML unmarshal failed: %v", err) }