mirror of
https://github.com/ivuorinen/gibidify.git
synced 2026-01-26 11:34:03 +00:00
test: fix linter package names (#23)
* test: fix linter package names * chore: pr-lint.yml
This commit is contained in:
4
.github/workflows/pr-lint.yml
vendored
4
.github/workflows/pr-lint.yml
vendored
@@ -11,10 +11,6 @@ on:
|
||||
|
||||
permissions: read-all
|
||||
|
||||
env:
|
||||
TRIVY_SEVERITY: CRITICAL,HIGH
|
||||
DISABLE_LINTERS: GO_GOLANGCI_LINT
|
||||
|
||||
jobs:
|
||||
Linter:
|
||||
name: PR Lint
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user