Skip to content

Commit f399ea0

Browse files
authored
Merge pull request #170 from buildkite/chore_testify_lint
chore: enable testify lint to make things tidy
2 parents b747083 + 45d929d commit f399ea0

File tree

9 files changed

+23
-16
lines changed

9 files changed

+23
-16
lines changed

.golangci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ linters:
88
- unused
99
- gosec
1010
- gocritic
11+
- testifylint
1112
exclusions:
1213
generated: lax
1314
presets:
@@ -34,6 +35,12 @@ formatters:
3435
replacement: "any"
3536
- pattern: "a[b:len(a)]"
3637
replacement: "a[b:]"
38+
testifylint:
39+
disable-all: true
40+
enable:
41+
- require-error
42+
- useless-assert
43+
- len
3744
exclusions:
3845
generated: lax
3946
paths:

pkg/buildkite/access_token_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ func TestAccessToken(t *testing.T) {
6363

6464
textContent := getTextResult(t, result)
6565

66-
assert.Equal(`{"uuid":"123","scopes":["read_build","read_pipeline"],"description":"Test token","created_at":"2023-01-01T00:00:00Z","user":{"name":"Test User","email":"[email protected]"}}`, textContent.Text)
66+
assert.JSONEq(`{"uuid":"123","scopes":["read_build","read_pipeline"],"description":"Test token","created_at":"2023-01-01T00:00:00Z","user":{"name":"Test User","email":"[email protected]"}}`, textContent.Text)
6767
}

pkg/buildkite/annotations_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ func TestListAnnotations(t *testing.T) {
5959
assert.NoError(err)
6060
textContent := getTextResult(t, result)
6161

62-
assert.Equal(`{"headers":{"Link":""},"items":[{"id":"1","body_html":"Test annotation 1"},{"id":"2","body_html":"Test annotation 2"}]}`, textContent.Text)
62+
assert.JSONEq(`{"headers":{"Link":""},"items":[{"id":"1","body_html":"Test annotation 1"},{"id":"2","body_html":"Test annotation 2"}]}`, textContent.Text)
6363
}

pkg/buildkite/builds_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,10 @@ func TestCreateBuild(t *testing.T) {
570570
CreateFunc: func(ctx context.Context, org string, pipeline string, b buildkite.CreateBuild) (buildkite.Build, *buildkite.Response, error) {
571571

572572
// Validate required fields
573-
assert.Equal(org, "org")
574-
assert.Equal(pipeline, "pipeline")
575-
assert.Equal(b.Commit, "abc123")
576-
assert.Equal(b.Message, "Test build")
573+
assert.Equal("org", org)
574+
assert.Equal("pipeline", pipeline)
575+
assert.Equal("abc123", b.Commit)
576+
assert.Equal("Test build", b.Message)
577577

578578
// Return created build
579579
return buildkite.Build{
@@ -619,7 +619,7 @@ func TestCreateBuild(t *testing.T) {
619619
assert.NoError(err)
620620

621621
textContent := getTextResult(t, result)
622-
assert.Equal(`{"id":"123","number":1,"state":"created","blocked":false,"author":{},"env":{"ENV_VAR":"value"},"created_at":"0001-01-01T00:00:00Z","meta_data":{"meta_key":"meta_value"},"creator":{"avatar_url":"","created_at":null,"email":"","id":"","name":""}}`, textContent.Text)
622+
assert.JSONEq(`{"id":"123","number":1,"state":"created","blocked":false,"author":{},"env":{"ENV_VAR":"value"},"created_at":"0001-01-01T00:00:00Z","meta_data":{"meta_key":"meta_value"},"creator":{"avatar_url":"","created_at":null,"email":"","id":"","name":""}}`, textContent.Text)
623623
}
624624

625625
func TestCalculatePercentage(t *testing.T) {

pkg/buildkite/cluster_queue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestListClusterQueues(t *testing.T) {
5959
assert.NoError(err)
6060

6161
textContent := getTextResult(t, result)
62-
assert.Equal(`{"headers":{"Link":""},"items":[{"id":"queue-id","dispatch_paused":false,"created_by":{}}]}`, textContent.Text)
62+
assert.JSONEq(`{"headers":{"Link":""},"items":[{"id":"queue-id","dispatch_paused":false,"created_by":{}}]}`, textContent.Text)
6363
}
6464

6565
func TestGetClusterQueue(t *testing.T) {
@@ -91,5 +91,5 @@ func TestGetClusterQueue(t *testing.T) {
9191
assert.NoError(err)
9292

9393
textContent := getTextResult(t, result)
94-
assert.Equal("{\"id\":\"queue-id\",\"dispatch_paused\":false,\"created_by\":{}}", textContent.Text)
94+
assert.JSONEq("{\"id\":\"queue-id\",\"dispatch_paused\":false,\"created_by\":{}}", textContent.Text)
9595
}

pkg/buildkite/clusters_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestListClusters(t *testing.T) {
5959
assert.NoError(err)
6060

6161
textContent := getTextResult(t, result)
62-
assert.Equal(`{"headers":{"Link":""},"items":[{"id":"cluster-id","name":"cluster-name","created_by":{}}]}`, textContent.Text)
62+
assert.JSONEq(`{"headers":{"Link":""},"items":[{"id":"cluster-id","name":"cluster-name","created_by":{}}]}`, textContent.Text)
6363
}
6464

6565
func TestGetCluster(t *testing.T) {
@@ -91,5 +91,5 @@ func TestGetCluster(t *testing.T) {
9191
assert.NoError(err)
9292

9393
textContent := getTextResult(t, result)
94-
assert.Equal("{\"id\":\"cluster-id\",\"name\":\"cluster-name\",\"created_by\":{}}", textContent.Text)
94+
assert.JSONEq("{\"id\":\"cluster-id\",\"name\":\"cluster-name\",\"created_by\":{}}", textContent.Text)
9595
}

pkg/buildkite/organizations_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestUserTokenOrganization(t *testing.T) {
4949

5050
textContent := getTextResult(t, result)
5151

52-
assert.Equal(`{"name":"Test Organization","slug":"test-org"}`, textContent.Text)
52+
assert.JSONEq(`{"name":"Test Organization","slug":"test-org"}`, textContent.Text)
5353
}
5454

5555
func TestUserTokenOrganizationError(t *testing.T) {

pkg/buildkite/pipelines_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func TestListPipelines(t *testing.T) {
9191

9292
textContent := getTextResult(t, result)
9393

94-
assert.Equal(`{"headers":{"Link":""},"items":[{"id":"123","name":"Test Pipeline","slug":"test-pipeline","repository":"","default_branch":"","web_url":"","visibility":"","created_at":"0001-01-01T00:00:00Z"}]}`, textContent.Text)
94+
assert.JSONEq(`{"headers":{"Link":""},"items":[{"id":"123","name":"Test Pipeline","slug":"test-pipeline","repository":"","default_branch":"","web_url":"","visibility":"","created_at":"0001-01-01T00:00:00Z"}]}`, textContent.Text)
9595
}
9696

9797
func TestGetPipeline(t *testing.T) {
@@ -129,7 +129,7 @@ func TestGetPipeline(t *testing.T) {
129129

130130
textContent := getTextResult(t, result)
131131

132-
assert.Equal(`{"id":"123","name":"Test Pipeline","slug":"test-pipeline","created_at":"0001-01-01T00:00:00Z","skip_queued_branch_builds":false,"cancel_running_branch_builds":false,"provider":{"id":"","webhook_url":"","settings":null}}`, textContent.Text)
132+
assert.JSONEq(`{"id":"123","name":"Test Pipeline","slug":"test-pipeline","created_at":"0001-01-01T00:00:00Z","skip_queued_branch_builds":false,"cancel_running_branch_builds":false,"provider":{"id":"","webhook_url":"","settings":null}}`, textContent.Text)
133133
}
134134

135135
func TestCreatePipeline(t *testing.T) {
@@ -417,5 +417,5 @@ steps:
417417
result, err := handler(ctx, request, args)
418418
assert.NoError(err)
419419
textContent := getTextResult(t, result)
420-
assert.Equal(`{"id":"123","name":"Test Pipeline","slug":"test-pipeline","created_at":"0001-01-01T00:00:00Z","skip_queued_branch_builds":false,"cancel_running_branch_builds":false,"cluster_id":"abc-123","tags":["tag1","tag2"],"provider":{"id":"","webhook_url":"","settings":null}}`, textContent.Text)
420+
assert.JSONEq(`{"id":"123","name":"Test Pipeline","slug":"test-pipeline","created_at":"0001-01-01T00:00:00Z","skip_queued_branch_builds":false,"cancel_running_branch_builds":false,"cluster_id":"abc-123","tags":["tag1","tag2"],"provider":{"id":"","webhook_url":"","settings":null}}`, textContent.Text)
421421
}

pkg/buildkite/user_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ func TestCurrentUser(t *testing.T) {
5050

5151
textContent := getTextResult(t, result)
5252

53-
assert.Equal(`{"id":"123","name":"Test User","email":"[email protected]","created_at":"0001-01-01T00:00:00Z"}`, textContent.Text)
53+
assert.JSONEq(`{"id":"123","name":"Test User","email":"[email protected]","created_at":"0001-01-01T00:00:00Z"}`, textContent.Text)
5454
}

0 commit comments

Comments
 (0)