Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce code format for tests #660

Merged
merged 7 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
- name: Run tidy
run: make tidy

- name: Run formatter
run: |
go install mvdan.cc/gofumpt@86bffd62437a3c437c0b84d5d5ab244824e762fc
gofumpt -l -w .

- name: Fail if changes
run: git diff-index --exit-code HEAD

Expand Down
34 changes: 17 additions & 17 deletions test/unit/stackscripts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
"golang.org/x/exp/slices"
)

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

var base ClientBaseCase
base.SetUp(t)
defer base.TearDown(t)
var base ClientBaseCase
base.SetUp(t)
defer base.TearDown(t)

// Mock the request with a correct paginated structure
base.MockGet("linode/stackscripts", fixtureData)
// Mock the request with a correct paginated structure
base.MockGet("linode/stackscripts", fixtureData)

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

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

// Check if a specific stackscript exists using slices.ContainsFunc
exists := slices.ContainsFunc(stackscripts, func(stackscript linodego.Stackscript) bool {
return stackscript.Label == "Test Stackscript"
})
// Check if a specific stackscript exists using slices.ContainsFunc
exists := slices.ContainsFunc(stackscripts, func(stackscript linodego.Stackscript) bool {
return stackscript.Label == "Test Stackscript"
})

assert.True(t, exists, "Expected stackscripts list to contain 'Test Stackscript'")
assert.True(t, exists, "Expected stackscripts list to contain 'Test Stackscript'")
}

func TestCreateStackscript(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions test/unit/tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func TestListTags(t *testing.T) {
assert.True(t, exists, "Expected tag list to contain 'example-tag'")
}


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


func TestDeleteTag(t *testing.T) {
var base ClientBaseCase
base.SetUp(t)
Expand Down Expand Up @@ -98,7 +96,6 @@ func TestListTaggedObjects(t *testing.T) {
}
}


func TestSortedObjects(t *testing.T) {
// Load the fixture data for tagged objects
fixtureData, err := fixtures.GetFixture("tagged_objects_list")
Expand Down
6 changes: 3 additions & 3 deletions test/unit/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package unit
import (
"context"
"fmt"
"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
"testing"
"golang.org/x/exp/slices"

"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
"golang.org/x/exp/slices"
)

func TestLinodeTypes_List(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions test/unit/vlan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package unit
import (
"context"
"fmt"
"testing"

"github.com/linode/linodego"
"github.com/stretchr/testify/assert"
"golang.org/x/exp/slices"
"testing"
"golang.org/x/exp/slices"
)

func TestVLAN_List(t *testing.T) {
Expand Down
Loading