test: fix linter package names (#23)

* test: fix linter package names

* chore: pr-lint.yml
This commit is contained in:
2025-07-14 01:48:39 +03:00
committed by GitHub
parent 70fede7635
commit 9a2bbda223
6 changed files with 28 additions and 25 deletions

View File

@@ -11,10 +11,6 @@ on:
permissions: read-all permissions: read-all
env:
TRIVY_SEVERITY: CRITICAL,HIGH
DISABLE_LINTERS: GO_GOLANGCI_LINT
jobs: jobs:
Linter: Linter:
name: PR Lint name: PR Lint

View File

@@ -1,10 +1,11 @@
package config package config_test
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
configpkg "github.com/ivuorinen/gibidify/config"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
@@ -26,15 +27,15 @@ func TestDefaultConfig(t *testing.T) {
originalConfigPaths := viper.ConfigFileUsed() originalConfigPaths := viper.ConfigFileUsed()
viper.Reset() viper.Reset()
viper.AddConfigPath(tmpDir) viper.AddConfigPath(tmpDir)
LoadConfig() configpkg.LoadConfig()
// Check defaults // Check defaults
defaultSizeLimit := GetFileSizeLimit() defaultSizeLimit := configpkg.GetFileSizeLimit()
if defaultSizeLimit != 5242880 { if defaultSizeLimit != 5242880 {
t.Errorf("Expected default file size limit of 5242880, got %d", defaultSizeLimit) t.Errorf("Expected default file size limit of 5242880, got %d", defaultSizeLimit)
} }
ignoredDirs := GetIgnoredDirectories() ignoredDirs := configpkg.GetIgnoredDirectories()
if len(ignoredDirs) == 0 { if len(ignoredDirs) == 0 {
t.Errorf("Expected some default ignored directories, got none") t.Errorf("Expected some default ignored directories, got none")
} }

View File

@@ -1,8 +1,10 @@
package fileproc package fileproc_test
import ( import (
"os" "os"
"testing" "testing"
fileproc "github.com/ivuorinen/gibidify/fileproc"
) )
func TestCollectFilesWithFakeWalker(t *testing.T) { func TestCollectFilesWithFakeWalker(t *testing.T) {
@@ -11,7 +13,7 @@ func TestCollectFilesWithFakeWalker(t *testing.T) {
"/path/to/file1.txt", "/path/to/file1.txt",
"/path/to/file2.go", "/path/to/file2.go",
} }
fake := FakeWalker{ fake := fileproc.FakeWalker{
Files: expectedFiles, Files: expectedFiles,
Err: nil, Err: nil,
} }
@@ -35,7 +37,7 @@ func TestCollectFilesWithFakeWalker(t *testing.T) {
func TestCollectFilesError(t *testing.T) { func TestCollectFilesError(t *testing.T) {
// Fake walker returns an error. // Fake walker returns an error.
fake := FakeWalker{ fake := fileproc.FakeWalker{
Files: nil, Files: nil,
Err: os.ErrNotExist, Err: os.ErrNotExist,
} }

View File

@@ -1,10 +1,12 @@
package fileproc package fileproc_test
import ( import (
"os" "os"
"strings" "strings"
"sync" "sync"
"testing" "testing"
fileproc "github.com/ivuorinen/gibidify/fileproc"
) )
func TestProcessFile(t *testing.T) { func TestProcessFile(t *testing.T) {
@@ -30,12 +32,12 @@ func TestProcessFile(t *testing.T) {
return return
} }
ch := make(chan WriteRequest, 1) ch := make(chan fileproc.WriteRequest, 1)
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
ProcessFile(tmpFile.Name(), ch, "") fileproc.ProcessFile(tmpFile.Name(), ch, "")
}() }()
wg.Wait() wg.Wait()
close(ch) close(ch)

View File

@@ -1,4 +1,4 @@
package fileproc package fileproc_test
import ( import (
"os" "os"
@@ -6,6 +6,7 @@ import (
"testing" "testing"
"github.com/ivuorinen/gibidify/config" "github.com/ivuorinen/gibidify/config"
fileproc "github.com/ivuorinen/gibidify/fileproc"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
@@ -53,7 +54,7 @@ func TestProdWalkerWithIgnore(t *testing.T) {
viper.Set("ignoreDirectories", []string{"vendor"}) viper.Set("ignoreDirectories", []string{"vendor"})
// Run walker // Run walker
var w Walker = ProdWalker{} var w fileproc.Walker = fileproc.ProdWalker{}
found, err := w.Walk(rootDir) found, err := w.Walk(rootDir)
if err != nil { if err != nil {
t.Fatalf("Walk returned error: %v", err) t.Fatalf("Walk returned error: %v", err)
@@ -96,7 +97,7 @@ func TestProdWalkerBinaryCheck(t *testing.T) {
config.LoadConfig() config.LoadConfig()
// Run walker // Run walker
var w Walker = ProdWalker{} var w fileproc.Walker = fileproc.ProdWalker{}
found, err := w.Walk(rootDir) found, err := w.Walk(rootDir)
if err != nil { if err != nil {
t.Fatalf("Walk returned error: %v", err) t.Fatalf("Walk returned error: %v", err)
@@ -139,7 +140,7 @@ func TestProdWalkerSizeLimit(t *testing.T) {
viper.Reset() viper.Reset()
config.LoadConfig() config.LoadConfig()
var w Walker = ProdWalker{} var w fileproc.Walker = fileproc.ProdWalker{}
found, err := w.Walk(rootDir) found, err := w.Walk(rootDir)
if err != nil { if err != nil {
t.Fatalf("Walk returned error: %v", err) t.Fatalf("Walk returned error: %v", err)

View File

@@ -1,4 +1,4 @@
package fileproc package fileproc_test
import ( import (
"encoding/json" "encoding/json"
@@ -7,6 +7,7 @@ import (
"sync" "sync"
"testing" "testing"
fileproc "github.com/ivuorinen/gibidify/fileproc"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )
@@ -55,12 +56,12 @@ func TestStartWriter_Formats(t *testing.T) {
}() }()
// Prepare channels // Prepare channels
writeCh := make(chan WriteRequest, 2) writeCh := make(chan fileproc.WriteRequest, 2)
doneCh := make(chan struct{}) doneCh := make(chan struct{})
// Write a couple of sample requests // Write a couple of sample requests
writeCh <- WriteRequest{Path: "sample.go", Content: "package main"} writeCh <- fileproc.WriteRequest{Path: "sample.go", Content: "package main"}
writeCh <- WriteRequest{Path: "example.py", Content: "def foo(): pass"} writeCh <- fileproc.WriteRequest{Path: "example.py", Content: "def foo(): pass"}
close(writeCh) close(writeCh)
// Start the writer // Start the writer
@@ -68,7 +69,7 @@ func TestStartWriter_Formats(t *testing.T) {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() 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 // Wait until writer signals completion
@@ -94,12 +95,12 @@ func TestStartWriter_Formats(t *testing.T) {
switch tc.format { switch tc.format {
case "json": case "json":
// Quick parse check // Quick parse check
var outStruct OutputData var outStruct fileproc.OutputData
if err := json.Unmarshal(data, &outStruct); err != nil { if err := json.Unmarshal(data, &outStruct); err != nil {
t.Errorf("JSON unmarshal failed: %v", err) t.Errorf("JSON unmarshal failed: %v", err)
} }
case "yaml": case "yaml":
var outStruct OutputData var outStruct fileproc.OutputData
if err := yaml.Unmarshal(data, &outStruct); err != nil { if err := yaml.Unmarshal(data, &outStruct); err != nil {
t.Errorf("YAML unmarshal failed: %v", err) t.Errorf("YAML unmarshal failed: %v", err)
} }