소스 검색

refactor: change detect tests to t.Fatal instead of log.Fatal (#1270)

Oleksandr Redko 2 년 전
부모
커밋
14b1ca9fd9
1개의 변경된 파일5개의 추가작업 그리고 6개의 파일을 삭제
  1. 5 6
      detect/detect_test.go

+ 5 - 6
detect/detect_test.go

@@ -6,7 +6,6 @@ import (
 	"path/filepath"
 	"path/filepath"
 	"testing"
 	"testing"
 
 
-	"github.com/rs/zerolog/log"
 	"github.com/spf13/viper"
 	"github.com/spf13/viper"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/assert"
 
 
@@ -479,7 +478,7 @@ func TestFromGit(t *testing.T) {
 		var ignorePath string
 		var ignorePath string
 		info, err := os.Stat(tt.source)
 		info, err := os.Stat(tt.source)
 		if err != nil {
 		if err != nil {
-			log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
+			t.Fatalf("could not os.Stat: %v", err)
 		}
 		}
 
 
 		if info.IsDir() {
 		if info.IsDir() {
@@ -488,7 +487,7 @@ func TestFromGit(t *testing.T) {
 			ignorePath = filepath.Join(filepath.Dir(tt.source), ".gitleaksignore")
 			ignorePath = filepath.Join(filepath.Dir(tt.source), ".gitleaksignore")
 		}
 		}
 		if err = detector.AddGitleaksIgnore(ignorePath); err != nil {
 		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)
 		findings, err := detector.DetectGit(tt.source, tt.logOpts, DetectType)
@@ -572,7 +571,7 @@ func TestFromGitStaged(t *testing.T) {
 		}
 		}
 		detector := NewDetector(cfg)
 		detector := NewDetector(cfg)
 		if err = detector.AddGitleaksIgnore(filepath.Join(tt.source, ".gitleaksignore")); err != nil {
 		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)
 		findings, err := detector.DetectGit(tt.source, tt.logOpts, ProtectStagedType)
 		if err != nil {
 		if err != nil {
@@ -663,7 +662,7 @@ func TestFromFiles(t *testing.T) {
 		var ignorePath string
 		var ignorePath string
 		info, err := os.Stat(tt.source)
 		info, err := os.Stat(tt.source)
 		if err != nil {
 		if err != nil {
-			log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
+			t.Fatalf("could not call os.Stat: %v", err)
 		}
 		}
 
 
 		if info.IsDir() {
 		if info.IsDir() {
@@ -672,7 +671,7 @@ func TestFromFiles(t *testing.T) {
 			ignorePath = filepath.Join(filepath.Dir(tt.source), ".gitleaksignore")
 			ignorePath = filepath.Join(filepath.Dir(tt.source), ".gitleaksignore")
 		}
 		}
 		if err = detector.AddGitleaksIgnore(ignorePath); err != nil {
 		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
 		detector.FollowSymlinks = true
 		findings, err := detector.DetectFiles(tt.source)
 		findings, err := detector.DetectFiles(tt.source)