Skip to content

Commit 300cfcd

Browse files
committed
refactor: simplify auth result structure and enable table output for wasp-cli auth login command
1 parent 9753980 commit 300cfcd

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

tools/cluster/tests/wasp-cli_test.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestWaspAuth(t *testing.T) {
3939

4040
t.Run("table format output", func(t *testing.T) {
4141
// t.Skip()
42-
out := w.MustRun("auth", "login", "--node=0", "-u=wasp", "-p=wasp")
42+
out := w.MustRun("auth", "login", "--node=0", "-u=wasp", "-p=wasp", "--table")
4343
// Check for table output format with SUCCESS status
4444
found := false
4545
for _, line := range out {
@@ -71,25 +71,22 @@ func TestWaspAuth(t *testing.T) {
7171
require.Contains(t, authResult, "type", "JSON output should contain 'type' field")
7272
require.Contains(t, authResult, "status", "JSON output should contain 'status' field")
7373
require.Contains(t, authResult, "timestamp", "JSON output should contain 'timestamp' field")
74-
require.Contains(t, authResult, "data", "JSON output should contain 'data' field")
7574

7675
// Verify top-level field values
7776
require.Equal(t, "auth", authResult["type"], "Expected type to be 'auth'")
7877
require.Equal(t, "success", authResult["status"], "Expected status to be 'success'")
7978
require.NotEmpty(t, authResult["timestamp"], "Timestamp should not be empty")
8079

81-
// Verify the data structure contains auth-specific fields
82-
data, ok := authResult["data"].(map[string]interface{})
83-
require.True(t, ok, "Data field should be an object")
84-
require.Contains(t, data, "node", "Auth data should contain 'node' field")
85-
require.Contains(t, data, "username", "Auth data should contain 'username' field")
80+
// Verify auth-specific fields are at the top level (no data wrapper)
81+
require.Contains(t, authResult, "node", "Auth result should contain 'node' field")
82+
require.Contains(t, authResult, "username", "Auth result should contain 'username' field")
8683

87-
// Verify the auth data values are correct
88-
require.Equal(t, "0", data["node"], "Expected node to be '0'")
89-
require.Equal(t, "wasp", data["username"], "Expected username to be 'wasp'")
84+
// Verify the auth values are correct
85+
require.Equal(t, "0", authResult["node"], "Expected node to be '0'")
86+
require.Equal(t, "wasp", authResult["username"], "Expected username to be 'wasp'")
9087

91-
// Check if the message field exists in data (it's optional)
92-
if message, exists := data["message"]; exists {
88+
// Check if the message field exists (it's optional)
89+
if message, exists := authResult["message"]; exists {
9390
require.NotEmpty(t, message, "Message field should not be empty if present")
9491
}
9592

0 commit comments

Comments
 (0)