Skip to content

Commit

Permalink
Update test to account for OS used.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrav committed May 2, 2022
1 parent 9a8af4b commit af7bbf5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/sources/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,39 +320,45 @@ func TestSource_Chunks_Edge_Cases(t *testing.T) {
func TestPrepareRepo(t *testing.T) {
tests := []struct {
uri string
path string
path bool
remote bool
err error
}{
{
uri: "https://github.com/dustin-decker/secretsandstuff.git",
path: "/var/folders/1m/m4kl5q2102bfr4k4566nmf800000gn/T/trufflehog2276311773",
path: true,
remote: true,
err: nil,
},
{
uri: "http://github.com/dustin-decker/secretsandstuff.git",
path: "/var/folders/1m/m4kl5q2102bfr4k4566nmf800000gn/T/trufflehog2276311773",
path: true,
remote: true,
err: nil,
},
{
uri: "file:///path/to/file.json",
path: "/var/folders/1m/m4kl5q2102bfr4k4566nmf800000gn/T/trufflehog2276311773",
path: true,
remote: false,
err: nil,
},
{
uri: "no bueno",
path: "",
path: false,
remote: false,
err: fmt.Errorf("unsupported Git URI: no bueno"),
},
}

for _, tt := range tests {
repo, b, err := PrepareRepo(tt.uri)
if repo != tt.path && b != tt.remote && err != tt.err {
var repoLen bool
if len(repo) > 0 {
repoLen = true
} else {
repoLen = false
}
if repoLen != tt.path || b != tt.remote {
t.Errorf("PrepareRepo(%v) got: %v, %v, %v want: %v, %v, %v", tt.uri, repo, b, err, tt.path, tt.remote, tt.err)
}
}
Expand Down

0 comments on commit af7bbf5

Please sign in to comment.