Repository navigation
Fix -o for large and unfinished batches, usage exit codes, and CSV columns #35
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b1a1ee2
Fix -o for large and unfinished batches, usage exit codes, and CSV co…
jclusso 746b6df
Drop unverified claim from the empty batch results error
jclusso 939b9a1
Stream downloaded CSV results row by row
jclusso 22c3e85
Classify every positional-arg error as invalid input
jclusso 6086cbb
Trim README additions for output fixes
jclusso e95b342
Merge branch 'master' into output-fixes
jclusso 302532f
Summarize large batches instead of printing the download URL
jclusso e11c229
Refuse empty partial saves and count large batches from progress
jclusso 228c004
Exclude duplicates from the large-batch verified count
jclusso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/emailable/emailable-cli/internal/credentials" | ||
| ) | ||
|
|
||
| func TestAccountStatus_JSONPassesThroughUnknownFields(t *testing.T) { | ||
| env := newTestEnv(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| writeJSON(w, map[string]any{"owner_email": "o@x.com", "available_credits": 5, "plan": "pro"}) | ||
| })) | ||
| env.seedAPIKey(t, "sk_test_xxx") | ||
|
|
||
| res := runRoot(t, "account", "status", "--json") | ||
| if res.Err != nil { | ||
| t.Fatalf("execute: %v", res.Err) | ||
| } | ||
| if payload := decodeJSON(t, res.Stdout.Bytes()); payload["plan"] != "pro" { | ||
| t.Errorf("expected unmodeled field to pass through, got %v", payload) | ||
| } | ||
|
|
||
| res = runRoot(t, "account", "status", "--jq", ".plan") | ||
| if res.Err != nil { | ||
| t.Fatalf("execute: %v", res.Err) | ||
| } | ||
| if got := strings.TrimSpace(res.Stdout.String()); got != "pro" { | ||
| t.Errorf("--jq .plan: got %q", got) | ||
| } | ||
| } | ||
|
|
||
| func seedStoredKeyWithEmail(t *testing.T, env *testEnv) { | ||
| t.Helper() | ||
| creds := &credentials.Credentials{APIKey: "sk_test_xxx", OwnerEmail: "owner@example.com"} | ||
| if err := creds.Save(env.CredentialsPath); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| } | ||
|
|
||
| func TestStatus_StoredAPIKeyShowsEmail(t *testing.T) { | ||
| env := newTestEnv(t, http.NotFoundHandler()) | ||
| seedStoredKeyWithEmail(t, env) | ||
|
|
||
| res := runRoot(t, "status", "--json") | ||
| if res.Err != nil { | ||
| t.Fatalf("execute: %v", res.Err) | ||
| } | ||
| if payload := decodeJSON(t, res.Stdout.Bytes()); payload["owner_email"] != "owner@example.com" { | ||
| t.Errorf("expected owner_email, got %v", payload) | ||
| } | ||
|
|
||
| res = runRoot(t, "status") | ||
| if res.Err != nil { | ||
| t.Fatalf("execute: %v", res.Err) | ||
| } | ||
| if !strings.Contains(res.Stdout.String(), "owner@example.com") { | ||
| t.Errorf("expected Account row, got %q", res.Stdout.String()) | ||
| } | ||
| } | ||
|
|
||
| func TestStatus_EnvAPIKeyHidesStoredEmail(t *testing.T) { | ||
| env := newTestEnv(t, http.NotFoundHandler()) | ||
| seedStoredKeyWithEmail(t, env) | ||
| t.Setenv("EMAILABLE_API_KEY", "sk_env_yyy") | ||
|
|
||
| res := runRoot(t, "status", "--json") | ||
| if res.Err != nil { | ||
| t.Fatalf("execute: %v", res.Err) | ||
| } | ||
| if payload := decodeJSON(t, res.Stdout.Bytes()); payload["owner_email"] != nil { | ||
| t.Errorf("stored email must not show for an env key, got %v", payload["owner_email"]) | ||
| } | ||
| res = runRoot(t, "status") | ||
| if strings.Contains(res.Stdout.String(), "owner@example.com") { | ||
| t.Errorf("stored email must not show for an env key, got %q", res.Stdout.String()) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.