Skip to content

Commit

Permalink
refactor: change detect tests to t.Fatal instead of log.Fatal (#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Sep 20, 2023
1 parent d9f86d6 commit 14b1ca9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions detect/detect_test.go
Expand Up @@ -6,7 +6,6 @@ import (
"path/filepath"
"testing"

"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"

Expand Down Expand Up @@ -479,7 +478,7 @@ func TestFromGit(t *testing.T) {
var ignorePath string
info, err := os.Stat(tt.source)
if err != nil {
log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
t.Fatalf("could not os.Stat: %v", err)
}

if info.IsDir() {
Expand All @@ -488,7 +487,7 @@ func TestFromGit(t *testing.T) {
ignorePath = filepath.Join(filepath.Dir(tt.source), ".gitleaksignore")
}
if err = detector.AddGitleaksIgnore(ignorePath); err != nil {
log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
t.Fatalf("could not call AddGitleaksIgnore: %v", err)
}

findings, err := detector.DetectGit(tt.source, tt.logOpts, DetectType)
Expand Down Expand Up @@ -572,7 +571,7 @@ func TestFromGitStaged(t *testing.T) {
}
detector := NewDetector(cfg)
if err = detector.AddGitleaksIgnore(filepath.Join(tt.source, ".gitleaksignore")); err != nil {
log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
t.Fatalf("could not call AddGitleaksIgnore: %v", err)
}
findings, err := detector.DetectGit(tt.source, tt.logOpts, ProtectStagedType)
if err != nil {
Expand Down Expand Up @@ -663,7 +662,7 @@ func TestFromFiles(t *testing.T) {
var ignorePath string
info, err := os.Stat(tt.source)
if err != nil {
log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
t.Fatalf("could not call os.Stat: %v", err)
}

if info.IsDir() {
Expand All @@ -672,7 +671,7 @@ func TestFromFiles(t *testing.T) {
ignorePath = filepath.Join(filepath.Dir(tt.source), ".gitleaksignore")
}
if err = detector.AddGitleaksIgnore(ignorePath); err != nil {
log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
t.Fatalf("could not call AddGitleaksIgnore: %v", err)
}
detector.FollowSymlinks = true
findings, err := detector.DetectFiles(tt.source)
Expand Down

0 comments on commit 14b1ca9

Please sign in to comment.