Skip to content

Commit f5039a5

Browse files
committed
feat(tests): Allow undeleteable type tests to fail.
chore(deps): Bump deps Signed-off-by: spbsoluble <[email protected]>
1 parent e213614 commit f5039a5

File tree

3 files changed

+82
-74
lines changed

3 files changed

+82
-74
lines changed

cmd/storeTypes_test.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func Test_StoreTypesCreateFromTemplatesCmd(t *testing.T) {
199199

200200
// Attempt to create the store type
201201
shortName := storeType["ShortName"].(string)
202-
createStoreTypeTest(t, shortName)
202+
createStoreTypeTest(t, shortName, false)
203203
}
204204
createAllStoreTypes(t, storeTypes)
205205
}
@@ -288,8 +288,9 @@ func deleteStoreTypeTest(t *testing.T, shortName string, allowFail bool) {
288288
deleteStoreOutput := captureOutput(
289289
func() {
290290
if checkIsUnDeleteable(shortName) {
291-
t.Skip("Not processing un-deletable store-type: ", shortName)
292-
return
291+
allowFail = true
292+
//t.Skip("Not processing un-deletable store-type: ", shortName)
293+
//return
293294
}
294295

295296
err := testCmd.Execute()
@@ -326,38 +327,45 @@ func checkIsUnDeleteable(shortName string) bool {
326327
return false
327328
}
328329

329-
func createStoreTypeTest(t *testing.T, shortName string) {
330+
func createStoreTypeTest(t *testing.T, shortName string, allowFail bool) {
330331
t.Run(
331332
fmt.Sprintf("CreateStore %s", shortName), func(t *testing.T) {
332333
testCmd := RootCmd
333334
if checkIsUnDeleteable(shortName) {
334-
t.Skip("Not processing un-deletable store-type: ", shortName)
335-
return
335+
t.Logf("WARNING: Allowing un-deletable store-type: %s to FAIL", shortName)
336+
allowFail = true
336337
}
337338
deleteStoreTypeTest(t, shortName, true)
338339
testCmd.SetArgs([]string{"store-types", "create", "--name", shortName})
339340
createStoreOutput := captureOutput(
340341
func() {
341342
err := testCmd.Execute()
342-
assert.NoError(t, err)
343+
if !allowFail {
344+
assert.NoError(t, err)
345+
}
343346
},
344347
)
345348

346349
// check if any of the undeleteable_exceptions are in the output
347350
for _, exception := range UndeleteableExceptions {
348351
if strings.Contains(createStoreOutput, exception) {
349-
t.Skip("Not processing un-deletable store-type: ", exception)
350-
return
352+
t.Logf(
353+
"WARNING: wxpected error encountered '%s' allowing un-deletable store-type: %s to FAIL",
354+
exception, shortName,
355+
)
356+
allowFail = true
351357
}
352358
}
353359

354-
if strings.Contains(createStoreOutput, "already exists") {
355-
assert.Fail(t, fmt.Sprintf("Store type %s already exists", shortName))
356-
} else if !strings.Contains(createStoreOutput, "created with ID") {
357-
assert.Fail(t, fmt.Sprintf("Store type %s was not created: %s", shortName, createStoreOutput))
360+
if !allowFail {
361+
if strings.Contains(createStoreOutput, "already exists") {
362+
assert.Fail(t, fmt.Sprintf("Store type %s already exists", shortName))
363+
} else if !strings.Contains(createStoreOutput, "created with ID") {
364+
assert.Fail(t, fmt.Sprintf("Store type %s was not created: %s", shortName, createStoreOutput))
365+
}
358366
}
359367
// Delete again after create
360-
deleteStoreTypeTest(t, shortName, false)
368+
deleteStoreTypeTest(t, shortName, allowFail)
361369
},
362370
)
363371
}

go.mod

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,45 @@ go 1.21
44

55
require (
66
github.com/AlecAivazis/survey/v2 v2.3.7
7-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2
8-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
7+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0
8+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0
99
github.com/Jeffail/gabs v1.4.0
1010
github.com/Keyfactor/keyfactor-go-client-sdk v1.0.2
11-
github.com/Keyfactor/keyfactor-go-client/v2 v2.2.10-rc.1
11+
github.com/Keyfactor/keyfactor-go-client/v2 v2.2.11
1212
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2
13-
github.com/creack/pty v1.1.21
14-
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
13+
github.com/creack/pty v1.1.23
1514
github.com/google/go-cmp v0.6.0
1615
github.com/google/uuid v1.6.0
1716
github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02
1817
github.com/joho/godotenv v1.5.1
19-
github.com/rs/zerolog v1.31.0
20-
github.com/spf13/cobra v1.8.0
18+
github.com/rs/zerolog v1.33.0
19+
github.com/spf13/cobra v1.8.1
2120
github.com/spf13/pflag v1.0.5
22-
github.com/stretchr/testify v1.8.4
23-
golang.org/x/crypto v0.19.0
21+
github.com/stretchr/testify v1.9.0
22+
golang.org/x/crypto v0.25.0
2423
gopkg.in/yaml.v3 v3.0.1
2524
//github.com/google/go-cmp/cmp v0.5.9
2625
)
2726

2827
require (
29-
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect
30-
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect
31-
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
28+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
29+
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
30+
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
3231
github.com/davecgh/go-spew v1.1.1 // indirect
33-
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
32+
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
3433
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3534
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
3635
github.com/kylelemons/godebug v1.1.0 // indirect
3736
github.com/mattn/go-colorable v0.1.13 // indirect
3837
github.com/mattn/go-isatty v0.0.19 // indirect
3938
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
40-
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
39+
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
4140
github.com/pmezard/go-difflib v1.0.0 // indirect
4241
github.com/russross/blackfriday/v2 v2.1.0 // indirect
4342
github.com/spbsoluble/go-pkcs12 v0.3.3 // indirect
4443
go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect
45-
golang.org/x/net v0.20.0 // indirect
46-
golang.org/x/sys v0.17.0 // indirect
47-
golang.org/x/term v0.17.0 // indirect
48-
golang.org/x/text v0.14.0 // indirect
44+
golang.org/x/net v0.27.0 // indirect
45+
golang.org/x/sys v0.22.0 // indirect
46+
golang.org/x/term v0.22.0 // indirect
47+
golang.org/x/text v0.16.0 // indirect
4948
)

0 commit comments

Comments
 (0)