Repository navigation
Fix test #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix test #42
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -422,7 +422,9 @@ func TestFilesUploadTransportParity(t *testing.T) { | |
| for _, mode := range [][]string{nil, {"--dry-run"}} { | ||
| args := []string{"--server-url", server.URL, "--api-version=" + version, "--api-key", "test-key", "--no-interactive", "--color", "never"} | ||
| result := runCLI(t, t.TempDir(), nil, append(args, append(mode, "files", "list")...)...) | ||
| if result.err == nil || strings.Contains(result.stderr, "[DRY-RUN]") || !strings.Contains(result.stderr, "API version must be non-empty") { | ||
| if result.err == nil || strings.Contains(result.stderr, "[DRY-RUN]") || | ||
| (!strings.Contains(result.stderr, "API version must be non-empty") && | ||
| !strings.Contains(result.stderr, "contains a dot segment")) { | ||
| t.Errorf("--api-version %q %v was accepted:\n%s", version, mode, result.stderr) | ||
| } | ||
|
Comment on lines
+425
to
429
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test assertions for invalid API versions are combined using a loose check. We should assert the specific expected error message based on whether the version is empty or contains a dot segment to ensure precise validation behavior. var wantErr string
if version == "" {
wantErr = "API version must be non-empty"
} else {
wantErr = "contains a dot segment"
}
if result.err == nil || strings.Contains(result.stderr, "[DRY-RUN]") || !strings.Contains(result.stderr, wantErr) {
t.Errorf("--api-version %q %v was accepted or did not fail with %q:\n%s", version, mode, wantErr, result.stderr)
} |
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -354,7 +354,7 @@ func TestTranscribeVideoMIME(t *testing.T) { | |
| // TestServerSelectionFlagOmitted pins the single-server CLI contract: | ||
| // --server is absent, while --server-url remains available. | ||
| func TestServerSelectionFlagOmitted(t *testing.T) { | ||
| result := runCLI(t, t.TempDir(), nil, "--server", "99", "tokens", "hi") | ||
| result := runCLI(t, t.TempDir(), nil, "--server", "99", "agent", "list") | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test to make sure we reject the unknown flag, but since we have updated to The --server got swallow into tokens, and since tokens accept unknown flag, so it would return a different error message, update the test to use agent as agent doesn't accept --server, so it checks if --server is a known persistent flag on the root command |
||
| if result.err == nil { | ||
| t.Fatal("unregistered --server unexpectedly succeeded") | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,8 +32,8 @@ func TestBodylessOperationsRequireTheirIdentifier(t *testing.T) { | |
| {[]string{"agent", "status"}, "--id"}, | ||
| {[]string{"triggers", "get"}, "--id"}, | ||
| {[]string{"triggers", "delete"}, "--id"}, | ||
| {[]string{"triggers", "run"}, "--trigger-id"}, | ||
| {[]string{"triggers", "list-executions"}, "--trigger-id"}, | ||
| {[]string{"triggers", "run"}, "--id"}, | ||
| {[]string{"triggers", "list-executions"}, "--id"}, | ||
| {[]string{"credentials", "get"}, "--id"}, | ||
| {[]string{"credentials", "delete"}, "--id"}, | ||
| {[]string{"environments", "get"}, "--id"}, | ||
|
|
@@ -54,7 +54,8 @@ func TestBodylessOperationsRequireTheirIdentifier(t *testing.T) { | |
| if code := exitCode(t, result); code != 2 { | ||
| t.Errorf("%v exit code = %d, want 2\nstderr: %s", mode, code, result.stderr) | ||
| } | ||
| if !strings.Contains(result.stderr, "missing required flag: "+tc.flag) { | ||
| if !strings.Contains(result.stderr, "missing required flag: "+tc.flag) && | ||
| !strings.Contains(result.stderr, "blank; path parameters require a non-empty value") { | ||
| t.Errorf("%v stderr missing the named flag %s:\n%s", mode, tc.flag, result.stderr) | ||
| } | ||
|
Comment on lines
+57
to
60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test assertions for absent vs empty/blank flags are combined using a loose 'neither' check. This reduces the precision of the test, as an absent flag could incorrectly pass if it triggers the path parameter validation instead of Cobra's required flag validation. We should assert the specific expected error message based on whether the flag is absent or empty/blank. var wantErr string
if label == "absent" {
wantErr = "missing required flag: " + tc.flag
} else {
wantErr = "blank; path parameters require a non-empty value"
}
if !strings.Contains(result.stderr, wantErr) {
t.Errorf("%v stderr missing expected error %q:\n%s", mode, wantErr, result.stderr)
} |
||
| if strings.Contains(result.stderr, "[DRY-RUN]") || requests.Load() != before { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is okay because we added
in internal/sdk/sdkinternal/utils/pathparams.go