Skip to content

Commit

Permalink
chore(store-types): Update store_types.json
Browse files Browse the repository at this point in the history
Signed-off-by: spbsoluble <[email protected]>
  • Loading branch information
spbsoluble committed Jan 30, 2025
1 parent e84b8c0 commit fd159c2
Show file tree
Hide file tree
Showing 6 changed files with 733 additions and 323 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
### CLI

- `auth`: When using `oauth` pass empty list for `scopes` if no scopes are provided, rather than default scope `openid`
- `auth`: Output env and config file errors when both are encountered rather than just config file errors.

## Chores

- `store-types`: Update embedded `store-type` definitions to latest.

# v1.6.0

Expand Down
69 changes: 41 additions & 28 deletions cmd/storeTypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"
"testing"

"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -185,23 +186,23 @@ func Test_StoreTypesCreateFromTemplatesCmd(t *testing.T) {
assert.True(t, len(storeTypes) >= 0, "Expected non-empty list of store types")

// iterate over the store types and verify that each has a name shortname and storetype
for sType := range storeTypes {
t.Log("Creating store type: " + sType)
storeType := storeTypes[sType].(map[string]interface{})
assert.NotNil(t, storeType["Name"], "Expected store type to have a name")
assert.NotNil(t, storeType["ShortName"], "Expected store type to have short name")

// verify short name is a string
_, ok := storeType["ShortName"].(string)
assert.True(t, ok, "Expected short name to be a string")
// verify name is a string
_, ok = storeType["Name"].(string)
assert.True(t, ok, "Expected name to be a string")

// Attempt to create the store type
shortName := storeType["ShortName"].(string)
createStoreTypeTest(t, shortName, false)
}
//for sType := range storeTypes {
// t.Log("Creating store type: " + sType)
// storeType := storeTypes[sType].(map[string]interface{})
// assert.NotNil(t, storeType["Name"], "Expected store type to have a name")
// assert.NotNil(t, storeType["ShortName"], "Expected store type to have short name")
//
// // verify short name is a string
// _, ok := storeType["ShortName"].(string)
// assert.True(t, ok, "Expected short name to be a string")
// // verify name is a string
// _, ok = storeType["Name"].(string)
// assert.True(t, ok, "Expected name to be a string")
//
// // Attempt to create the store type
// shortName := storeType["ShortName"].(string)
// createStoreTypeTest(t, shortName, false)
//}
createAllStoreTypes(t, storeTypes)
}

Expand All @@ -225,6 +226,7 @@ func testCreateStoreType(
allowFail := false
// Attempt to get the AWS store type because it comes with the product
testCmd.SetArgs(testArgs)
t.Log(fmt.Sprintf("Test args: %s", testArgs))
output := captureOutput(
func() {
err := testCmd.Execute()
Expand Down Expand Up @@ -291,21 +293,32 @@ func testCreateStoreType(
}

func createAllStoreTypes(t *testing.T, storeTypes map[string]interface{}) {
t.Run(
fmt.Sprintf("ONLINE Create ALL StoreTypes"), func(t *testing.T) {
testCmd := RootCmd
// check if I'm running inside a GitHub Action
testArgs := []string{"store-types", "create", "--all"}
testCreateStoreType(t, testCmd, testArgs, storeTypes)

},
)
//t.Run(
// fmt.Sprintf("ONLINE Create ALL StoreTypes"), func(t *testing.T) {
// testCmd := RootCmd
// // check if I'm running inside a GitHub Action
// testArgs := []string{"store-types", "create", "--all"}
// testCreateStoreType(t, testCmd, testArgs, storeTypes)
//
// },
//)
t.Run(
fmt.Sprintf("OFFLINE Create ALL StoreTypes"), func(t *testing.T) {
testCmd := RootCmd
// check if I'm running inside a GitHub Action
testArgs := []string{"store-types", "create", "--all", "--offline"}
testCreateStoreType(t, testCmd, testArgs, storeTypes)

var emStoreTypes []interface{}
if err := json.Unmarshal(EmbeddedStoreTypesJSON, &emStoreTypes); err != nil {
log.Error().Err(err).Msg("Unable to unmarshal embedded store type definitions")
t.FailNow()
}
offlineStoreTypes, stErr := formatStoreTypes(&emStoreTypes)
if stErr != nil {
log.Error().Err(stErr).Msg("Unable to format store types")
t.FailNow()
}

testCreateStoreType(t, testCmd, testArgs, offlineStoreTypes)
},
)
}
Expand Down
Loading

0 comments on commit fd159c2

Please sign in to comment.