Skip to content

Commit 7a8e6b1

Browse files
Veeral Patelveeral-patel
authored andcommitted
fix tests
1 parent cb3b0de commit 7a8e6b1

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

tools/tdbg/task_queue_commands.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ func AdminGetTaskQueueUserData(c *cli.Context, clientFactory ClientFactory) erro
218218

219219
ctx, cancel := newContext(c)
220220
defer cancel()
221-
if response, e := client.GetTaskQueueUserData(ctx, req); e != nil {
221+
response, e := client.GetTaskQueueUserData(ctx, req)
222+
if e != nil {
222223
return fmt.Errorf("unable to get Task Queue User Data: %w", e)
223-
} else {
224-
prettyPrintJSONObject(c, response)
225224
}
225+
prettyPrintJSONObject(c, response)
226226
return nil
227227
}
228228

tools/tdbg/task_queue_commands_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (s *taskQueueCommandTestSuite) TestForceUnloadTaskQueuePartition() {
175175
// TestGetTaskQueueUserData tests that the cli accepts the various arguments for get-user-data.
176176
func (s *taskQueueCommandTestSuite) TestGetTaskQueueUserData() {
177177
baseCommand := []string{"tdbg", "taskqueue", "get-user-data",
178-
"--task-queue", "test"}
178+
"--namespace", "default", "--task-queue", "test"}
179179

180180
// Run shared test cases, skipping sticky-name (not a registered flag on this command).
181181
for _, test := range testCases {
@@ -184,17 +184,22 @@ func (s *taskQueueCommandTestSuite) TestGetTaskQueueUserData() {
184184
}
185185
cliCommand := append(baseCommand, test.inputFlags...)
186186
resp := s.app.Run(cliCommand)
187-
if resp != nil {
187+
if test.err != nil {
188188
s.ErrorContainsf(resp, test.err.Error(), "error present")
189+
} else {
190+
s.NoError(resp)
189191
}
190192
}
191193

192194
// Missing --task-queue is enforced by cli/v2 (Required: true) before the action runs.
193-
s.Error(s.app.Run([]string{"tdbg", "taskqueue", "get-user-data"}))
195+
s.Error(s.app.Run([]string{"tdbg", "taskqueue", "get-user-data", "--namespace", "default"}))
196+
197+
// Missing --namespace is enforced by cli/v2 (Required: true) before the action runs.
198+
s.Error(s.app.Run([]string{"tdbg", "taskqueue", "get-user-data", "--task-queue", "test"}))
194199

195200
// No --task-queue-type or --partition-id: both use their defaults and succeed.
196201
s.NoError(s.app.Run([]string{"tdbg", "taskqueue", "get-user-data",
197-
"--task-queue", "test"}))
202+
"--namespace", "default", "--task-queue", "test"}))
198203

199204
// Matching client returns an error: CLI wraps and returns it.
200205
errorClient := &testClient{
@@ -205,6 +210,6 @@ func (s *taskQueueCommandTestSuite) TestGetTaskQueueUserData() {
205210
errorApp := NewCliApp(func(params *Params) { params.ClientFactory = errorClient })
206211
errorApp.ExitErrHandler = func(context *cli.Context, err error) {}
207212
resp := errorApp.Run([]string{"tdbg", "taskqueue", "get-user-data",
208-
"--task-queue", "test"})
213+
"--namespace", "default", "--task-queue", "test"})
209214
s.ErrorContains(resp, "unable to get Task Queue User Data")
210215
}

0 commit comments

Comments
 (0)