Skip to content

Commit

Permalink
Merge pull request cloudflare#583 from cloudflare/tests
Browse files Browse the repository at this point in the history
Cleanup tests
  • Loading branch information
prymitive authored Mar 20, 2023
2 parents f02d2be + dc1d265 commit 00b5164
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 39 deletions.
39 changes: 0 additions & 39 deletions internal/reporter/bitbucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ import (
"github.com/cloudflare/pint/internal/reporter"
)

func blameLine(sha string, line int, filename, content string) string {
return fmt.Sprintf(`%s %d %d 1
filename %s
%s
`, sha, line, line, filename, content)
}

func TestBitBucketReporter(t *testing.T) {
zerolog.SetGlobalLevel(zerolog.FatalLevel)

Expand Down Expand Up @@ -71,10 +64,6 @@ func TestBitBucketReporter(t *testing.T) {
if args[0] == "rev-parse" {
return []byte("fake-commit-id"), nil
}
if args[0] == "blame" {
content := blameLine("fake-commit-id", 2, "foo.txt", "up == 0")
return []byte(content), nil
}
return nil, nil
},
reports: []reporter.Report{
Expand Down Expand Up @@ -103,10 +92,6 @@ func TestBitBucketReporter(t *testing.T) {
if args[0] == "rev-parse" {
return []byte("fake-commit-id"), nil
}
if args[0] == "blame" {
content := blameLine("fake-commit-id", 2, "foo.txt", "up == 0")
return []byte(content), nil
}
return nil, nil
},
reports: []reporter.Report{
Expand Down Expand Up @@ -137,10 +122,6 @@ func TestBitBucketReporter(t *testing.T) {
if args[0] == "rev-parse" {
return []byte("fake-commit-id"), nil
}
if args[0] == "blame" {
content := blameLine("fake-commit-id", 2, "foo.txt", "up == 0")
return []byte(content), nil
}
return nil, nil
},
reports: []reporter.Report{
Expand Down Expand Up @@ -171,10 +152,6 @@ func TestBitBucketReporter(t *testing.T) {
if args[0] == "rev-parse" {
return []byte("fake-commit-id"), nil
}
if args[0] == "blame" {
content := blameLine("fake-commit-id", 2, "foo.txt", "up == 0") + blameLine("fake-commit-id", 4, "foo.txt", "errors")
return []byte(content), nil
}
return nil, nil
},
reports: []reporter.Report{
Expand Down Expand Up @@ -299,14 +276,6 @@ func TestBitBucketReporter(t *testing.T) {
if args[0] == "rev-parse" {
return []byte("fake-commit-id"), nil
}
if args[0] == "blame" {
content := blameLine("fake-commit-00", 1, "foo.txt", "ignore") +
blameLine("fake-commit-00", 2, "foo.txt", "ignore") +
blameLine("fake-commit-id", 3, "foo.txt", "ok") +
blameLine("fake-commit-id", 4, "foo.txt", "syntax error") +
blameLine("fake-commit-01", 5, "foo.txt", "ignore")
return []byte(content), nil
}
return nil, nil
},
reports: []reporter.Report{
Expand Down Expand Up @@ -363,10 +332,6 @@ func TestBitBucketReporter(t *testing.T) {
if args[0] == "rev-parse" {
return []byte("fake-commit-id"), nil
}
if args[0] == "blame" {
content := blameLine("fake-commit-id", 2, "foo.txt", "up == 0") + blameLine("fake-commit-id", 4, "foo.txt", "errors")
return []byte(content), nil
}
return nil, nil
},
report: reporter.BitBucketReport{
Expand Down Expand Up @@ -396,10 +361,6 @@ func TestBitBucketReporter(t *testing.T) {
if args[0] == "rev-parse" {
return []byte("fake-commit-id"), nil
}
if args[0] == "blame" {
content := blameLine("fake-commit-id", 4, "foo.txt", "errors")
return []byte(content), nil
}
return nil, nil
},
reports: []reporter.Report{
Expand Down
7 changes: 7 additions & 0 deletions internal/reporter/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ func TestGithubReporter(t *testing.T) {
expr: sum(errors) by (job)
`))

blameLine := func(sha string, line int, filename, content string) string {
return fmt.Sprintf(`%s %d %d 1
filename %s
%s
`, sha, line, line, filename, content)
}

for _, tc := range []testCaseT{
{
description: "timeout errors out",
Expand Down

0 comments on commit 00b5164

Please sign in to comment.