Skip to content

Commit

Permalink
Format import statement, remove extra lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ShajithaMohammed committed Oct 25, 2021
1 parent 8f3fcb8 commit 28bab18
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
8 changes: 0 additions & 8 deletions test/e2e/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ data:

secondData := NewPresentClusterResource("configmap", "second", env.Namespace, kubectl).RawPath(ctlres.NewPathFromStrings([]string{"data"}))
require.Exactlyf(t, map[string]interface{}{"keep": "", "keep2": "", "delete": ""}, secondData, "Expected value to be correct")

})
}

Expand Down Expand Up @@ -191,15 +190,13 @@ secrets:
RunOpts{IntoNs: true, StdinReader: strings.NewReader(yaml1)})

secrets := NewPresentClusterResource("serviceaccount", "test-sa-with-secrets", env.Namespace, kubectl).RawPath(ctlres.NewPathFromStrings([]string{"secrets"})).([]interface{})

require.Len(t, secrets, 2, "Expected one set and one generated secret")
require.Exactlyf(t, map[string]interface{}{"name": "some-secret"}, secrets[0], "Expected provided secret at idx0: %#v", secrets[0])

generatedSecretName = secrets[1].(map[string]interface{})["name"].(string)
require.True(t, strings.HasPrefix(generatedSecretName, "test-sa-with-secrets-token-"), "Expected generated secret at idx1: %#v", secrets[1])

secrets = NewPresentClusterResource("serviceaccount", "test-sa-without-secrets", env.Namespace, kubectl).RawPath(ctlres.NewPathFromStrings([]string{"secrets"})).([]interface{})

require.Len(t, secrets, 1, "Expected one set and one generated secret")
require.True(t, strings.HasPrefix(secrets[0].(map[string]interface{})["name"].(string), "test-sa-without-secrets-token-"), "Expected generated secret at idx0: %#v", secrets[0])
})
Expand All @@ -226,12 +223,10 @@ secrets:
RunOpts{IntoNs: true, StdinReader: strings.NewReader(yaml2)})

secrets := NewPresentClusterResource("serviceaccount", "test-sa-with-secrets", env.Namespace, kubectl).RawPath(ctlres.NewPathFromStrings([]string{"secrets"})).([]interface{})

require.Len(t, secrets, 3, "Expected one set and one generated secret")
require.Exactlyf(t, map[string]interface{}{"name": "some-secret"}, secrets[0], "Expected provided secret at idx0")
require.Exactlyf(t, map[string]interface{}{"name": "new-some-secret"}, secrets[1], "Expected provided secret at idx1")
require.Exactlyf(t, map[string]interface{}{"name": generatedSecretName}, secrets[2], "Expected previous generated secret at idx2")

})

ensureDeploysWithNoChanges(yaml2)
Expand All @@ -241,16 +236,13 @@ secrets:
RunOpts{IntoNs: true, StdinReader: strings.NewReader(yaml3)})

secrets := NewPresentClusterResource("serviceaccount", "test-sa-with-secrets", env.Namespace, kubectl).RawPath(ctlres.NewPathFromStrings([]string{"secrets"})).([]interface{})

require.Len(t, secrets, 1, "Expected one set and one generated secret")
require.Exactlyf(t, map[string]interface{}{"name": generatedSecretName}, secrets[0], "Expected previous generated secret at idx0")

secrets = NewPresentClusterResource("serviceaccount", "test-sa-without-secrets", env.Namespace, kubectl).RawPath(ctlres.NewPathFromStrings([]string{"secrets"})).([]interface{})

require.Len(t, secrets, 2, "Expected one set and one generated secret")
require.Exactlyf(t, map[string]interface{}{"name": "some-secret"}, secrets[0], "Expected provided secret at idx0")
require.True(t, strings.HasPrefix(secrets[1].(map[string]interface{})["name"].(string), "test-sa-without-secrets-token-"), "Expected generated secret at idx1: %#v", secrets[1])

})

ensureDeploysWithNoChanges(yaml3)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ func (e Env) Validate(t *testing.T) {
errStrs = append(errStrs, "Expected Namespace to be non-empty")
}

require.Len(t, errStrs, 0, "%s", strings.Join(errStrs, "\n"))
require.Lenf(t, errStrs, 0, "%s", strings.Join(errStrs, "\n"))
}
3 changes: 2 additions & 1 deletion test/e2e/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
package e2e

import (
"github.com/stretchr/testify/require"
"testing"

"github.com/stretchr/testify/require"
)

func TestVersion(t *testing.T) {
Expand Down
18 changes: 9 additions & 9 deletions test/e2e/warnings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@ Succeeded`
expectedOutput = strings.TrimSpace(replaceSpaces(expectedOutput))

require.Equal(t, expectedOutput, out)
})

logger.Section("deploying with --warnings flag", func() {
yaml := strings.Replace(crYaml, "<cr-name>", "cr-2", 1)
logger.Section("deploying with --warnings flag", func() {
yaml := strings.Replace(crYaml, "<cr-name>", "cr-2", 1)

out, _ := kapp.RunWithOpts([]string{"deploy", "-f", "-", "-a", crName2, "--warnings=false"},
RunOpts{StdinReader: strings.NewReader(yaml)})
out, _ := kapp.RunWithOpts([]string{"deploy", "-f", "-", "-a", crName2, "--warnings=false"},
RunOpts{StdinReader: strings.NewReader(yaml)})

expectedOutput := `
expectedOutput := `
Changes
Namespace Name Kind Conds. Age Op Op st. Wait to Rs Ri
Expand All @@ -134,11 +135,10 @@ Wait to: 1 reconcile, 0 delete, 0 noop
Succeeded`

out = strings.TrimSpace(replaceTarget(replaceSpaces(replaceTs(out))))
expectedOutput = strings.TrimSpace(replaceSpaces(expectedOutput))
out = strings.TrimSpace(replaceTarget(replaceSpaces(replaceTs(out))))
expectedOutput = strings.TrimSpace(replaceSpaces(expectedOutput))

require.Equal(t, expectedOutput, out)
})
require.Equal(t, expectedOutput, out)
})
}

Expand Down

0 comments on commit 28bab18

Please sign in to comment.