Skip to content

Commit

Permalink
Enable testifylint linter
Browse files Browse the repository at this point in the history
  • Loading branch information
phillebaba committed May 16, 2024
1 parent 75c9826 commit 55f5937
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ linters:
- goheader
- goimports
- nolintlint
- testifylint
linters-settings:
govet:
enable-all: true
Expand Down Expand Up @@ -50,6 +51,8 @@ linters-settings:
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
testifylint:
enable-all: true
issues:
# Revive rules that are disabled by default.
include:
Expand Down
23 changes: 10 additions & 13 deletions src/extensions/bigbang/bigbang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,26 @@ import (
func TestRequiredBigBangVersions(t *testing.T) {
// Support 1.54.0 and beyond
vv, err := isValidVersion("1.54.0")
require.Equal(t, err, nil)
require.Equal(t, vv, true)
require.NoError(t, err)
require.True(t, vv)

// Do not support earlier than 1.54.0
vv, err = isValidVersion("1.53.0")
require.Equal(t, err, nil)
require.Equal(t, vv, false)
require.NoError(t, err)
require.False(t, vv)

// Support for Big Bang release candidates
vv, err = isValidVersion("1.57.0-rc.0")
require.Equal(t, err, nil)
require.Equal(t, vv, true)
require.NoError(t, err)
require.True(t, vv)

// Support for Big Bang 2.0.0
vv, err = isValidVersion("2.0.0")
require.Equal(t, err, nil)
require.Equal(t, vv, true)
require.NoError(t, err)
require.True(t, vv)

// Fail on non-semantic versions
vv, err = isValidVersion("1.57b")
Expected := "Invalid Semantic Version"
if err.Error() != Expected {
t.Errorf("Error actual = %v, and Expected = %v.", err, Expected)
}
require.Equal(t, vv, false)
require.EqualError(t, err, "Invalid Semantic Version")
require.False(t, vv)
}
7 changes: 3 additions & 4 deletions src/pkg/packager/lint/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestValidateSchema(t *testing.T) {
"https://dev.azure.com/defenseunicorns/zarf-public-test/_git/zarf-public-test@v0.0.1"}}
checkForUnpinnedRepos(&validator, &composer.Node{ZarfComponent: component})
require.Equal(t, unpinnedRepo, validator.findings[0].item)
require.Equal(t, len(validator.findings), 1)
require.Len(t, validator.findings, 1)
})

t.Run("Unpinnned image warning", func(t *testing.T) {
Expand All @@ -133,8 +133,7 @@ func TestValidateSchema(t *testing.T) {
checkForUnpinnedImages(&validator, &composer.Node{ZarfComponent: component})
require.Equal(t, unpinnedImage, validator.findings[0].item)
require.Equal(t, badImage, validator.findings[1].item)
require.Equal(t, 2, len(validator.findings))

require.Len(t, validator.findings, 2)
})

t.Run("Unpinnned file warning", func(t *testing.T) {
Expand All @@ -156,7 +155,7 @@ func TestValidateSchema(t *testing.T) {
component := types.ZarfComponent{Files: zarfFiles}
checkForUnpinnedFiles(&validator, &composer.Node{ZarfComponent: component})
require.Equal(t, fileURL, validator.findings[0].item)
require.Equal(t, 1, len(validator.findings))
require.Len(t, validator.findings, 1)
})

t.Run("Wrap standalone numbers in bracket", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/00_use_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestUseCLI(t *testing.T) {
// Test `zarf version`
version, _, err := e2e.Zarf("version")
require.NoError(t, err)
require.NotEqual(t, len(version), 0, "Zarf version should not be an empty string")
require.NotEmpty(t, version, "Zarf version should not be an empty string")
version = strings.Trim(version, "\n")

// test `zarf version --output=json`
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/05_tarball_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestMultiPartPackage(t *testing.T) {
require.NoError(t, err)
err = json.Unmarshal(part0File, &pkgData)
require.NoError(t, err)
require.Equal(t, pkgData.Count, 3)
require.Equal(t, 3, pkgData.Count)
fmt.Printf("%#v", pkgData)

stdOut, stdErr, err = e2e.Zarf("package", "deploy", deployPath, "--confirm")
Expand Down
8 changes: 4 additions & 4 deletions src/test/e2e/21_connect_creds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func TestConnectAndCreds(t *testing.T) {
require.Contains(t, stdOut, "2.8.3")
stdOut, stdErr, err = e2e.Zarf("tools", "registry", "ls", "127.0.0.1:31337/grafana/promtail")
require.NoError(t, err, stdOut, stdErr)
require.Equal(t, stdOut, "")
require.Empty(t, stdOut)
stdOut, stdErr, err = e2e.Zarf("tools", "registry", "ls", "127.0.0.1:31337/grafana/grafana")
require.NoError(t, err, stdOut, stdErr)
require.Equal(t, stdOut, "")
require.Empty(t, stdOut)
stdOut, stdErr, err = e2e.Zarf("tools", "registry", "ls", "127.0.0.1:31337/grafana/loki")
require.NoError(t, err, stdOut, stdErr)
require.Equal(t, stdOut, "")
require.Empty(t, stdOut)
}

func TestMetrics(t *testing.T) {
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestMetrics(t *testing.T) {
}

desiredString := "go_gc_duration_seconds_count"
require.Equal(t, true, strings.Contains(string(body), desiredString))
require.Contains(t, string(body), desiredString)
require.NoError(t, err, resp)
require.Equal(t, 200, resp.StatusCode)
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/e2e/51_oci_compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ func (suite *SkeletonSuite) Test_2_FilePaths() {
}

func (suite *SkeletonSuite) DirOrFileExists(path string) {
suite.T().Helper()

invalid := helpers.InvalidPath(path)
suite.Falsef(invalid, "path specified does not exist: %s", path)
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/external/ext_out_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ func (suite *ExtOutClusterTestSuite) Test_2_AuthToPrivateHelmChart() {
}

func (suite *ExtOutClusterTestSuite) createHelmChartInGitea(baseURL string, username string, password string) {
suite.T().Helper()

tempDir := suite.T().TempDir()
podInfoVersion := "6.4.0"
podinfoChartPath := filepath.Join("..", "..", "..", "examples", "helm-charts", "chart")
Expand Down Expand Up @@ -223,6 +225,8 @@ func (suite *ExtOutClusterTestSuite) createHelmChartInGitea(baseURL string, user
}

func (suite *ExtOutClusterTestSuite) makeGiteaUserPrivate(baseURL string, username string, password string) {
suite.T().Helper()

url := fmt.Sprintf("%s/api/v1/admin/users/%s", baseURL, username)

userOption := map[string]interface{}{
Expand Down

0 comments on commit 55f5937

Please sign in to comment.