From dc1d265306e353d0d82bb1b280b2bea01225c310 Mon Sep 17 00:00:00 2001 From: Lukasz Mierzwa Date: Mon, 20 Mar 2023 16:29:40 +0000 Subject: [PATCH] Cleanup tests --- internal/reporter/bitbucket_test.go | 39 ----------------------------- internal/reporter/github_test.go | 7 ++++++ 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/internal/reporter/bitbucket_test.go b/internal/reporter/bitbucket_test.go index 4fc352e9..7e872322 100644 --- a/internal/reporter/bitbucket_test.go +++ b/internal/reporter/bitbucket_test.go @@ -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) @@ -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{ @@ -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{ @@ -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{ @@ -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{ @@ -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{ @@ -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{ @@ -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{ diff --git a/internal/reporter/github_test.go b/internal/reporter/github_test.go index d14574a6..d0aa4ded 100644 --- a/internal/reporter/github_test.go +++ b/internal/reporter/github_test.go @@ -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",