Skip to content

Commit a35570e

Browse files
Enforce code format for tests (#660)
* Enforce code format including tests * Format existing tests * gofumpt * gofumpt
1 parent c5cc32a commit a35570e

File tree

14 files changed

+67
-59
lines changed

14 files changed

+67
-59
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ jobs:
2424
- name: Run tidy
2525
run: make tidy
2626

27+
- name: Run formatter
28+
run: |
29+
go install mvdan.cc/gofumpt@86bffd62437a3c437c0b84d5d5ab244824e762fc
30+
gofumpt -l -w .
31+
2732
- name: Fail if changes
2833
run: git diff-index --exit-code HEAD
2934

test/integration/lke_clusters_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ func TestLKECluster_APLEnabled_smoke(t *testing.T) {
343343
func(createOpts *linodego.LKEClusterCreateOptions) {
344344
// NOTE: g6-dedicated-4 is the minimum APL-compatible Linode type
345345
createOpts.NodePools = []linodego.LKENodePoolCreateOptions{{Count: 3, Type: "g6-dedicated-4", Tags: []string{"test"}}}
346-
}},
346+
},
347+
},
347348
"fixtures/TestLKECluster_APLEnabled")
348349
defer teardown()
349350

test/unit/domain_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package unit
33
import (
44
"context"
55
"fmt"
6-
"github.com/jarcoal/httpmock"
76
"testing"
87

8+
"github.com/jarcoal/httpmock"
9+
910
"github.com/linode/linodego"
1011
"github.com/stretchr/testify/assert"
1112
)

test/unit/domainrecord_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package unit
33
import (
44
"context"
55
"fmt"
6+
"testing"
7+
"time"
8+
69
"github.com/jarcoal/httpmock"
710
"github.com/linode/linodego"
811
"github.com/stretchr/testify/assert"
9-
"testing"
10-
"time"
1112
)
1213

1314
func TestDomainRecord_List(t *testing.T) {

test/unit/longview_subscriptions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"context"
55
"testing"
66

7-
"github.com/stretchr/testify/assert"
87
"github.com/linode/linodego"
8+
"github.com/stretchr/testify/assert"
99
)
1010

1111
func TestListLongviewSubscriptions(t *testing.T) {

test/unit/longview_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/stretchr/testify/assert"
98
"github.com/linode/linodego"
9+
"github.com/stretchr/testify/assert"
1010
)
1111

1212
func TestListLongviewClients(t *testing.T) {

test/unit/mysql_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package unit
22

33
import (
44
"context"
5-
"github.com/jarcoal/httpmock"
65
"testing"
76

7+
"github.com/jarcoal/httpmock"
8+
89
"github.com/linode/linodego"
910
"github.com/stretchr/testify/assert"
1011
)

test/unit/postgres_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package unit
22

33
import (
44
"context"
5+
"testing"
6+
57
"github.com/jarcoal/httpmock"
68
"github.com/linode/linodego"
79
"github.com/stretchr/testify/assert"
8-
"testing"
910
)
1011

1112
func TestListDatabasePostgreSQL_List(t *testing.T) {

test/unit/stackscripts_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,34 @@ import (
55
"fmt"
66
"testing"
77

8-
"github.com/stretchr/testify/assert"
98
"github.com/linode/linodego"
9+
"github.com/stretchr/testify/assert"
1010
"golang.org/x/exp/slices"
1111
)
1212

1313
func TestListStackscripts(t *testing.T) {
14-
// Mock the API response to match the expected structure for a paginated response
15-
fixtureData, err := fixtures.GetFixture("stackscripts_list")
16-
assert.NoError(t, err)
14+
// Mock the API response to match the expected structure for a paginated response
15+
fixtureData, err := fixtures.GetFixture("stackscripts_list")
16+
assert.NoError(t, err)
1717

18-
var base ClientBaseCase
19-
base.SetUp(t)
20-
defer base.TearDown(t)
18+
var base ClientBaseCase
19+
base.SetUp(t)
20+
defer base.TearDown(t)
2121

22-
// Mock the request with a correct paginated structure
23-
base.MockGet("linode/stackscripts", fixtureData)
22+
// Mock the request with a correct paginated structure
23+
base.MockGet("linode/stackscripts", fixtureData)
2424

25-
stackscripts, err := base.Client.ListStackscripts(context.Background(), &linodego.ListOptions{})
26-
assert.NoError(t, err)
25+
stackscripts, err := base.Client.ListStackscripts(context.Background(), &linodego.ListOptions{})
26+
assert.NoError(t, err)
2727

28-
assert.NotEmpty(t, stackscripts, "Expected non-empty stackscripts list")
28+
assert.NotEmpty(t, stackscripts, "Expected non-empty stackscripts list")
2929

30-
// Check if a specific stackscript exists using slices.ContainsFunc
31-
exists := slices.ContainsFunc(stackscripts, func(stackscript linodego.Stackscript) bool {
32-
return stackscript.Label == "Test Stackscript"
33-
})
30+
// Check if a specific stackscript exists using slices.ContainsFunc
31+
exists := slices.ContainsFunc(stackscripts, func(stackscript linodego.Stackscript) bool {
32+
return stackscript.Label == "Test Stackscript"
33+
})
3434

35-
assert.True(t, exists, "Expected stackscripts list to contain 'Test Stackscript'")
35+
assert.True(t, exists, "Expected stackscripts list to contain 'Test Stackscript'")
3636
}
3737

3838
func TestCreateStackscript(t *testing.T) {

test/unit/tag_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func TestListTags(t *testing.T) {
3434
assert.True(t, exists, "Expected tag list to contain 'example-tag'")
3535
}
3636

37-
3837
func TestCreateTag(t *testing.T) {
3938
// Load the fixture data for tag creation
4039
fixtureData, err := fixtures.GetFixture("tag_create")
@@ -57,7 +56,6 @@ func TestCreateTag(t *testing.T) {
5756
assert.Equal(t, "new-tag", tag.Label, "Expected created tag label to match input")
5857
}
5958

60-
6159
func TestDeleteTag(t *testing.T) {
6260
var base ClientBaseCase
6361
base.SetUp(t)
@@ -98,7 +96,6 @@ func TestListTaggedObjects(t *testing.T) {
9896
}
9997
}
10098

101-
10299
func TestSortedObjects(t *testing.T) {
103100
// Load the fixture data for tagged objects
104101
fixtureData, err := fixtures.GetFixture("tagged_objects_list")

0 commit comments

Comments
 (0)