Skip to content

Commit

Permalink
chore(lint): fix lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Techritz <[email protected]>
  • Loading branch information
maximiliantech committed Aug 16, 2024
1 parent d3c381d commit c05002a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
38 changes: 19 additions & 19 deletions pkg/envvar/envvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,37 @@ func (suite *EnvVarTestSuite) TearDownTest() {
}

func (suite *EnvVarTestSuite) TestGet() {
suite.T().Run("Returns existing env vars", func(t *testing.T) {
require.Equal(t, "", Get("ENVVARTEST_EMPTY"))
require.Equal(t, "This is a single line", Get("ENVVARTEST_SINGLE"))
require.Equal(t, "This\nis\na multiline string!", Get("ENVVARTEST_MULTILINE"))
suite.Run("Returns existing env vars", func() {
require.Equal(suite.T(), "", Get("ENVVARTEST_EMPTY"))

Check failure on line 34 in pkg/envvar/envvar_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-dont-use-pkg: use suite.Require().Equal (testifylint)
require.Equal(suite.T(), "This is a single line", Get("ENVVARTEST_SINGLE"))

Check failure on line 35 in pkg/envvar/envvar_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-dont-use-pkg: use suite.Require().Equal (testifylint)
require.Equal(suite.T(), "This\nis\na multiline string!", Get("ENVVARTEST_MULTILINE"))

Check failure on line 36 in pkg/envvar/envvar_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-dont-use-pkg: use suite.Require().Equal (testifylint)
})
suite.T().Run("Returns empty string if env var can't be found", func(t *testing.T) {
suite.Run("Returns empty string if env var can't be found", func() {
suite.Require().Empty(Get("ENVVARTEST_DOESNT_EXIST"))
})
}

func (suite *EnvVarTestSuite) TestGetOrDefault() {
suite.T().Run("Returns existing env vars", func(t *testing.T) {
require.Equal(t, "", GetOrDefault("ENVVARTEST_EMPTY", ""))
require.Equal(t, "This is a single line", GetOrDefault("ENVVARTEST_SINGLE", ""))
require.Equal(t, "This\nis\na multiline string!", GetOrDefault("ENVVARTEST_MULTILINE", ""))
suite.Run("Returns existing env vars", func() {
require.Equal(suite.T(), "", GetOrDefault("ENVVARTEST_EMPTY", ""))

Check failure on line 45 in pkg/envvar/envvar_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-dont-use-pkg: use suite.Require().Equal (testifylint)
require.Equal(suite.T(), "This is a single line", GetOrDefault("ENVVARTEST_SINGLE", ""))

Check failure on line 46 in pkg/envvar/envvar_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-dont-use-pkg: use suite.Require().Equal (testifylint)
require.Equal(suite.T(), "This\nis\na multiline string!", GetOrDefault("ENVVARTEST_MULTILINE", ""))

Check failure on line 47 in pkg/envvar/envvar_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-dont-use-pkg: use suite.Require().Equal (testifylint)
})
suite.T().Run("Returns default value if env var can't be found", func(t *testing.T) {
require.Equal(t, "a default value", GetOrDefault("ENVVARTEST_DOESNT_EXIST", "a default value"))
require.Equal(t, "another default value", GetOrDefault("ENVVARTEST_DOESNT_EXIST", "another default value"))
suite.Run("Returns default value if env var can't be found", func() {
require.Equal(suite.T(), "a default value", GetOrDefault("ENVVARTEST_DOESNT_EXIST", "a default value"))

Check failure on line 50 in pkg/envvar/envvar_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-dont-use-pkg: use suite.Require().Equal (testifylint)
require.Equal(suite.T(), "another default value", GetOrDefault("ENVVARTEST_DOESNT_EXIST", "another default value"))

Check failure on line 51 in pkg/envvar/envvar_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-dont-use-pkg: use suite.Require().Equal (testifylint)
})
}

func (suite *EnvVarTestSuite) TestGetOrPanic() {
suite.T().Run("Returns existing env vars", func(t *testing.T) {
require.Equal(t, "", GetOrPanic("ENVVARTEST_EMPTY"))
require.Equal(t, "This is a single line", GetOrPanic("ENVVARTEST_SINGLE"))
require.Equal(t, "This\nis\na multiline string!", GetOrPanic("ENVVARTEST_MULTILINE"))
suite.Run("Returns existing env vars", func() {
require.Equal(suite.T(), "", GetOrPanic("ENVVARTEST_EMPTY"))

Check failure on line 57 in pkg/envvar/envvar_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-dont-use-pkg: use suite.Require().Equal (testifylint)
require.Equal(suite.T(), "This is a single line", GetOrPanic("ENVVARTEST_SINGLE"))

Check failure on line 58 in pkg/envvar/envvar_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-dont-use-pkg: use suite.Require().Equal (testifylint)
require.Equal(suite.T(), "This\nis\na multiline string!", GetOrPanic("ENVVARTEST_MULTILINE"))
})
suite.T().Run("Panics if env var can't be found", func(t *testing.T) {
require.Panics(t, func() { GetOrPanic("ENVVARTEST_DOESNT_EXIST") })
require.Panics(t, func() { GetOrPanic("ENVVARTEST_DOESNT_EXIST") })
suite.Run("Panics if env var can't be found", func() {
require.Panics(suite.T(), func() { GetOrPanic("ENVVARTEST_DOESNT_EXIST") })
require.Panics(suite.T(), func() { GetOrPanic("ENVVARTEST_DOESNT_EXIST") })
})
}

Expand Down
20 changes: 10 additions & 10 deletions pkg/images/lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ func (suite *LookupSuite) TestGetImagesFromJSONOrPanic() {
packageKey := "foo"
controllerKey := "baz"

suite.T().Run("Returns both images from environment", func(t *testing.T) {
suite.Run("Returns both images from environment", func() {
err := os.Setenv("E2E_IMAGES", "{\"foo\": \"bar\", \"baz\": \"boom\"}")
println(err)
providerImages := GetImagesFromEnvironmentOrPanic(packageKey, &controllerKey)
require.Equal(t, "bar", providerImages.Package)
require.Equal(t, "boom", *providerImages.ControllerImage)
require.Equal(suite.T(), "bar", providerImages.Package)
require.Equal(suite.T(), "boom", *providerImages.ControllerImage)
})

suite.T().Run("Returns existing env vars", func(t *testing.T) {
suite.Run("Returns existing env vars", func() {
os.Setenv("E2E_IMAGES", "{\"foo\": \"bar\"}")
providerImages := GetImagesFromEnvironmentOrPanic(packageKey, nil)
require.Equal(t, "bar", providerImages.Package)
require.Nil(t, providerImages.ControllerImage)
require.Equal(suite.T(), "bar", providerImages.Package)
require.Nil(suite.T(), providerImages.ControllerImage)
})

suite.T().Run("env var not set, will panic", func(t *testing.T) {
suite.Run("env var not set, will panic", func() {
os.Unsetenv("E2E_IMAGES")
require.Panics(t, func() {
require.Panics(suite.T(), func() {
GetImagesFromEnvironmentOrPanic(packageKey, nil)
})
})

suite.T().Run("invalid json, will panic", func(t *testing.T) {
suite.Run("invalid json, will panic", func() {
os.Setenv("E2E_IMAGES", "//invalid.json")
require.Panics(t, func() {
require.Panics(suite.T(), func() {
GetImagesFromEnvironmentOrPanic(packageKey, nil)
})
})
Expand Down

0 comments on commit c05002a

Please sign in to comment.