From a9ccb6552d05a5dd39985a7e218c87e2b3ebe832 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 29 Sep 2022 15:34:20 +0200 Subject: [PATCH] cli/compose: remove redundant reflection from tests Signed-off-by: Sebastiaan van Stijn --- cli/compose/loader/loader_test.go | 15 +++++++-------- cli/compose/template/template_test.go | 5 ++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cli/compose/loader/loader_test.go b/cli/compose/loader/loader_test.go index 31e7f1af10..cdd214ca1b 100644 --- a/cli/compose/loader/loader_test.go +++ b/cli/compose/loader/loader_test.go @@ -3,7 +3,6 @@ package loader import ( "bytes" "os" - "reflect" "sort" "testing" "time" @@ -792,8 +791,10 @@ services: // Default behavior keeps the `env_file` entries configWithEnvFiles, err := Load(configDetails) assert.NilError(t, err) - assert.DeepEqual(t, configWithEnvFiles.Services[0].EnvFile, types.StringList{"example1.env", - "example2.env"}) + assert.DeepEqual(t, configWithEnvFiles.Services[0].EnvFile, types.StringList{ + "example1.env", + "example2.env", + }) assert.DeepEqual(t, configWithEnvFiles.Services[0].Environment, expectedEnvironmentMap) // Custom behavior removes the `env_file` entries @@ -862,7 +863,7 @@ services: service: foo `) - assert.ErrorType(t, err, reflect.TypeOf(&ForbiddenPropertiesError{})) + assert.ErrorType(t, err, &ForbiddenPropertiesError{}) props := err.(*ForbiddenPropertiesError).Properties assert.Check(t, is.Len(props, 2)) @@ -1343,7 +1344,6 @@ func TestLoadVolumesWarnOnDeprecatedExternalNameVersion34(t *testing.T) { } assert.Check(t, is.DeepEqual(expected, volumes)) assert.Check(t, is.Contains(buf.String(), "volume.external.name is deprecated")) - } func patchLogrus() (*bytes.Buffer, func()) { @@ -1483,7 +1483,6 @@ func TestLoadNetworksWarnOnDeprecatedExternalNameVersion35(t *testing.T) { } assert.Check(t, is.DeepEqual(expected, networks)) assert.Check(t, is.Contains(buf.String(), "network.external.name is deprecated")) - } func TestLoadNetworksWarnOnDeprecatedExternalNameVersion34(t *testing.T) { @@ -1564,7 +1563,7 @@ func TestLoadInit(t *testing.T) { booleanTrue := true booleanFalse := false - var testcases = []struct { + testcases := []struct { doc string yaml string init *bool @@ -1651,7 +1650,7 @@ services: } func TestTransform(t *testing.T) { - var source = []interface{}{ + source := []interface{}{ "80-82:8080-8082", "90-92:8090-8092/udp", "85:8500", diff --git a/cli/compose/template/template_test.go b/cli/compose/template/template_test.go index e8b3a5aae3..0406969900 100644 --- a/cli/compose/template/template_test.go +++ b/cli/compose/template/template_test.go @@ -2,7 +2,6 @@ package template import ( "fmt" - "reflect" "testing" "gotest.tools/v3/assert" @@ -125,8 +124,8 @@ func TestMandatoryVariableErrors(t *testing.T) { for _, tc := range testCases { _, err := Substitute(tc.template, defaultMapping) - assert.ErrorContains(t, err, tc.expectedError) - assert.ErrorType(t, err, reflect.TypeOf(&InvalidTemplateError{})) + assert.Check(t, is.ErrorContains(err, tc.expectedError)) + assert.Check(t, is.ErrorType(err, &InvalidTemplateError{})) } }