Skip to content

Commit

Permalink
feat(tests): Allow undeleteable type tests to fail.
Browse files Browse the repository at this point in the history
chore(deps): Bump deps

Signed-off-by: spbsoluble <[email protected]>
  • Loading branch information
spbsoluble committed Sep 8, 2024
1 parent e213614 commit f5039a5
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 74 deletions.
36 changes: 22 additions & 14 deletions cmd/storeTypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func Test_StoreTypesCreateFromTemplatesCmd(t *testing.T) {

// Attempt to create the store type
shortName := storeType["ShortName"].(string)
createStoreTypeTest(t, shortName)
createStoreTypeTest(t, shortName, false)
}
createAllStoreTypes(t, storeTypes)
}
Expand Down Expand Up @@ -288,8 +288,9 @@ func deleteStoreTypeTest(t *testing.T, shortName string, allowFail bool) {
deleteStoreOutput := captureOutput(
func() {
if checkIsUnDeleteable(shortName) {
t.Skip("Not processing un-deletable store-type: ", shortName)
return
allowFail = true
//t.Skip("Not processing un-deletable store-type: ", shortName)
//return
}

err := testCmd.Execute()
Expand Down Expand Up @@ -326,38 +327,45 @@ func checkIsUnDeleteable(shortName string) bool {
return false
}

func createStoreTypeTest(t *testing.T, shortName string) {
func createStoreTypeTest(t *testing.T, shortName string, allowFail bool) {
t.Run(
fmt.Sprintf("CreateStore %s", shortName), func(t *testing.T) {
testCmd := RootCmd
if checkIsUnDeleteable(shortName) {
t.Skip("Not processing un-deletable store-type: ", shortName)
return
t.Logf("WARNING: Allowing un-deletable store-type: %s to FAIL", shortName)
allowFail = true
}
deleteStoreTypeTest(t, shortName, true)
testCmd.SetArgs([]string{"store-types", "create", "--name", shortName})
createStoreOutput := captureOutput(
func() {
err := testCmd.Execute()
assert.NoError(t, err)
if !allowFail {
assert.NoError(t, err)
}
},
)

// check if any of the undeleteable_exceptions are in the output
for _, exception := range UndeleteableExceptions {
if strings.Contains(createStoreOutput, exception) {
t.Skip("Not processing un-deletable store-type: ", exception)
return
t.Logf(
"WARNING: wxpected error encountered '%s' allowing un-deletable store-type: %s to FAIL",
exception, shortName,
)
allowFail = true
}
}

if strings.Contains(createStoreOutput, "already exists") {
assert.Fail(t, fmt.Sprintf("Store type %s already exists", shortName))
} else if !strings.Contains(createStoreOutput, "created with ID") {
assert.Fail(t, fmt.Sprintf("Store type %s was not created: %s", shortName, createStoreOutput))
if !allowFail {
if strings.Contains(createStoreOutput, "already exists") {
assert.Fail(t, fmt.Sprintf("Store type %s already exists", shortName))
} else if !strings.Contains(createStoreOutput, "created with ID") {
assert.Fail(t, fmt.Sprintf("Store type %s was not created: %s", shortName, createStoreOutput))
}
}
// Delete again after create
deleteStoreTypeTest(t, shortName, false)
deleteStoreTypeTest(t, shortName, allowFail)
},
)
}
35 changes: 17 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,45 @@ go 1.21

require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0
github.com/Jeffail/gabs v1.4.0
github.com/Keyfactor/keyfactor-go-client-sdk v1.0.2
github.com/Keyfactor/keyfactor-go-client/v2 v2.2.10-rc.1
github.com/Keyfactor/keyfactor-go-client/v2 v2.2.11
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2
github.com/creack/pty v1.1.21
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/creack/pty v1.1.23
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02
github.com/joho/godotenv v1.5.1
github.com/rs/zerolog v1.31.0
github.com/spf13/cobra v1.8.0
github.com/rs/zerolog v1.33.0
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.19.0
github.com/stretchr/testify v1.9.0
golang.org/x/crypto v0.25.0
gopkg.in/yaml.v3 v3.0.1
//github.com/google/go-cmp/cmp v0.5.9
)

require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spbsoluble/go-pkcs12 v0.3.3 // indirect
go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
)
Loading

0 comments on commit f5039a5

Please sign in to comment.