Skip to content

Commit

Permalink
Merge pull request #226 from alrayyes/feat/testifylint
Browse files Browse the repository at this point in the history
test: enable testifylint
  • Loading branch information
alrayyes authored Dec 18, 2024
2 parents b40c72b + 077559c commit 0f97476
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 111 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ linters:
- unparam
- unused
- govet
- testifylint
4 changes: 2 additions & 2 deletions internal/provider/dedicatedserver/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Test_greaterThanZeroValidator_ValidateString(t *testing.T) {
greaterThanZeroValidator := greaterThanZero()
greaterThanZeroValidator.ValidateString(context.TODO(), request, &response)

assert.Len(t, response.Diagnostics.Errors(), 0)
assert.Empty(t, response.Diagnostics.Errors())
})

t.Run("does not set errors if the float value is greater than 0", func(t *testing.T) {
Expand All @@ -33,7 +33,7 @@ func Test_greaterThanZeroValidator_ValidateString(t *testing.T) {
greaterThanZeroValidator := greaterThanZero()
greaterThanZeroValidator.ValidateString(context.TODO(), request, &response)

assert.Len(t, response.Diagnostics.Errors(), 0)
assert.Empty(t, response.Diagnostics.Errors())
})

t.Run("set errors if the value is 0", func(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/publiccloud/image_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/leaseweb/leaseweb-go-sdk/v3/publiccloud"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_adaptImageToImageResource(t *testing.T) {
Expand Down Expand Up @@ -74,7 +75,7 @@ func Test_adaptImageDetailsToImageResource(t *testing.T) {
sdkImageDetails,
)

assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, want, *got)
}

Expand Down
61 changes: 31 additions & 30 deletions internal/provider/publiccloud/instance_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/leaseweb/leaseweb-go-sdk/v3/publiccloud"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_adaptContractToContractResource(t *testing.T) {
Expand Down Expand Up @@ -128,7 +129,7 @@ func Test_adaptInstanceDetailsToInstanceResource(t *testing.T) {

got, err := adaptInstanceDetailsToInstanceResource(instance, context.TODO())

assert.NoError(t, err)
require.NoError(t, err)

assert.Equal(t, "id", got.ID.ValueString())
assert.Equal(t, "region", got.Region.ValueString())
Expand Down Expand Up @@ -166,7 +167,7 @@ func Test_instanceResourceModel_getLaunchOpts(t *testing.T) {

got, err := instance.getLaunchOpts(context.TODO())

assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, publiccloud.REGIONNAME_EU_WEST_3, got.Region)
assert.Equal(t, publiccloud.TYPENAME_M5A_4XLARGE, got.Type)
assert.Equal(t, publiccloud.STORAGETYPE_CENTRAL, got.RootDiskStorageType)
Expand All @@ -190,7 +191,7 @@ func Test_instanceResourceModel_getLaunchOpts(t *testing.T) {

got, err := instance.getLaunchOpts(context.TODO())

assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, "marketAppId", *got.MarketAppId)
assert.Equal(t, "reference", *got.Reference)
assert.Equal(t, int32(55), *got.RootDiskSize)
Expand All @@ -204,8 +205,8 @@ func Test_instanceResourceModel_getLaunchOpts(t *testing.T) {

_, err := instance.getLaunchOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, "tralala")
require.Error(t, err)
require.ErrorContains(t, err, "tralala")
},
)

Expand All @@ -217,8 +218,8 @@ func Test_instanceResourceModel_getLaunchOpts(t *testing.T) {

_, err := instance.getLaunchOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, "tralala")
require.Error(t, err)
require.ErrorContains(t, err, "tralala")
},
)

Expand All @@ -232,8 +233,8 @@ func Test_instanceResourceModel_getLaunchOpts(t *testing.T) {

_, err := instance.getLaunchOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, "tralala")
require.Error(t, err)
require.ErrorContains(t, err, "tralala")
},
)

Expand All @@ -247,8 +248,8 @@ func Test_instanceResourceModel_getLaunchOpts(t *testing.T) {

_, err := instance.getLaunchOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, "555")
require.Error(t, err)
require.ErrorContains(t, err, "555")
},
)

Expand All @@ -262,8 +263,8 @@ func Test_instanceResourceModel_getLaunchOpts(t *testing.T) {

_, err := instance.getLaunchOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, "555")
require.Error(t, err)
require.ErrorContains(t, err, "555")
},
)

Expand All @@ -273,8 +274,8 @@ func Test_instanceResourceModel_getLaunchOpts(t *testing.T) {

_, err := instance.getLaunchOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, "tralala")
require.Error(t, err)
require.ErrorContains(t, err, "tralala")
})

t.Run(
Expand All @@ -285,8 +286,8 @@ func Test_instanceResourceModel_getLaunchOpts(t *testing.T) {

_, err := instance.getLaunchOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, ".imageResourceModel")
require.Error(t, err)
require.ErrorContains(t, err, ".imageResourceModel")
},
)

Expand All @@ -298,8 +299,8 @@ func Test_instanceResourceModel_getLaunchOpts(t *testing.T) {

_, err := instance.getLaunchOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, ".contractResourceModel")
require.Error(t, err)
require.ErrorContains(t, err, ".contractResourceModel")
},
)
}
Expand All @@ -310,7 +311,7 @@ func Test_instanceResourceModel_getUpdateOpts(t *testing.T) {

got, err := instance.getUpdateOpts(context.TODO())

assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, publiccloud.TYPENAME_M5A_4XLARGE, *got.Type)
assert.Equal(t, publiccloud.CONTRACTTYPE_MONTHLY, *got.ContractType)
assert.Equal(t, publiccloud.CONTRACTTERM__3, *got.ContractTerm)
Expand All @@ -327,8 +328,8 @@ func Test_instanceResourceModel_getUpdateOpts(t *testing.T) {

_, err := instance.getUpdateOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, "tralala")
require.Error(t, err)
require.ErrorContains(t, err, "tralala")
},
)

Expand All @@ -342,8 +343,8 @@ func Test_instanceResourceModel_getUpdateOpts(t *testing.T) {

_, err := instance.getUpdateOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, "tralala")
require.Error(t, err)
require.ErrorContains(t, err, "tralala")
},
)

Expand All @@ -357,8 +358,8 @@ func Test_instanceResourceModel_getUpdateOpts(t *testing.T) {

_, err := instance.getUpdateOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, "555")
require.Error(t, err)
require.ErrorContains(t, err, "555")
},
)

Expand All @@ -372,8 +373,8 @@ func Test_instanceResourceModel_getUpdateOpts(t *testing.T) {

_, err := instance.getUpdateOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, "555")
require.Error(t, err)
require.ErrorContains(t, err, "555")
},
)

Expand All @@ -385,8 +386,8 @@ func Test_instanceResourceModel_getUpdateOpts(t *testing.T) {

_, err := instance.getUpdateOpts(context.TODO())

assert.Error(t, err)
assert.ErrorContains(t, err, ".contractResourceModel")
require.Error(t, err)
require.ErrorContains(t, err, ".contractResourceModel")
},
)
}
Loading

0 comments on commit 0f97476

Please sign in to comment.