(t *testing.T)
| 351 | } |
| 352 | |
| 353 | func TestCompletionJSONUnsupportedOutputReturnsError(t *testing.T) { |
| 354 | t.Setenv(envAccessToken, "") |
| 355 | t.Setenv(envAuthFile, filepath.Join(t.TempDir(), "missing-auth.json")) |
| 356 | |
| 357 | var stdout bytes.Buffer |
| 358 | var stderr bytes.Buffer |
| 359 | root := &cobra.Command{ |
| 360 | Use: "dbxcli", |
| 361 | SilenceUsage: true, |
| 362 | SilenceErrors: true, |
| 363 | PersistentPreRunE: initDbx, |
| 364 | } |
| 365 | root.SetOut(&stdout) |
| 366 | root.SetErr(&stderr) |
| 367 | root.SetArgs([]string{"completion", "--output=json"}) |
| 368 | root.PersistentFlags().BoolP("verbose", "v", false, "") |
| 369 | root.PersistentFlags().String(outputFlag, "text", "") |
| 370 | root.PersistentFlags().String("as-member", "", "") |
| 371 | root.PersistentFlags().String("domain", "", "") |
| 372 | root.AddCommand(newCompletionCmd()) |
| 373 | |
| 374 | err := root.Execute() |
| 375 | if !errors.Is(err, output.ErrStructuredOutputUnsupported) { |
| 376 | t.Fatalf("error = %v, want structured output unsupported", err) |
| 377 | } |
| 378 | if got := stdout.String(); got != "" { |
| 379 | t.Fatalf("stdout = %q, want no text help output", got) |
| 380 | } |
| 381 | if got := stderr.String(); got != "" { |
| 382 | t.Fatalf("stderr = %q, want empty", got) |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | func TestHelpOutputRemainsTextWithJSONFlag(t *testing.T) { |
| 387 | tests := []struct { |
nothing calls this directly
no test coverage detected