Skip to content

Commit

Permalink
Fixing corner case of listing datastores when on no-tracing mode (#2585)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbdias committed May 24, 2023
1 parent 968de72 commit aaecf00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions cli/formatters/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ func (f DatastoreFormatter) ToStruct(file *file.File) (interface{}, error) {

func (f DatastoreFormatter) ToListStruct(file *file.File) ([]interface{}, error) {
var dataStoreList openapi.DataStoreList
nullableList := openapi.NewNullableDataStoreList(&dataStoreList)

err := nullableList.UnmarshalJSON([]byte(file.Contents()))
err := yaml.Unmarshal([]byte(file.Contents()), &dataStoreList)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ func TestListDatastore(t *testing.T) {
// Given I am a Tracetest CLI user
// And I have my server recently created

// When I try to list datastore on pretty mode and there is no datastore
// Then it should print an empty table
result := tracetestcli.Exec(t, "list datastore --output pretty", tracetestcli.WithCLIConfig(cliConfig))
helpers.RequireExitCodeEqual(t, result, 0)
require.NotContains(result.StdOut, "current")

// When I try to set up a new datastore
// Then it should be applied with success
dataStorePath := env.GetEnvironmentResourcePath(t, "data-store")

result := tracetestcli.Exec(t, fmt.Sprintf("apply datastore --file %s", dataStorePath), tracetestcli.WithCLIConfig(cliConfig))
result = tracetestcli.Exec(t, fmt.Sprintf("apply datastore --file %s", dataStorePath), tracetestcli.WithCLIConfig(cliConfig))
helpers.RequireExitCodeEqual(t, result, 0)

// When I try to list datastore again on pretty mode
Expand Down

0 comments on commit aaecf00

Please sign in to comment.