mirror of
https://github.com/4ier/notion-cli.git
synced 2026-09-14 20:17:00 +08:00
5d37c1b145
- Auto-prefix /v1 when a path starts with / but not /v1/, with a stderr note so power users see the rewrite. Previously `notion api GET /users/me` returned an opaque 'invalid_request_url' error. - Support `--body @file.json` (curl-style) and `--body -` for explicit stdin reads. The existing implicit stdin fallback for POST/PATCH/PUT still works. - Reject GET requests with a body up-front instead of silently dropping it. - Route PATCH through c.Patch() unconditionally (previously it hit c.Post first and was overwritten, which made error paths confusing). - Drop the misleading positional-arg example from --help; the flag was the only supported form. Closes #24
26 lines
508 B
Go
26 lines
508 B
Go
package cmd
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeAPIPath(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
want string
|
|
}{
|
|
{"/v1/users/me", "/v1/users/me"},
|
|
{"/v1", "/v1"},
|
|
{"/users/me", "/v1/users/me"},
|
|
{"users/me", "/v1/users/me"},
|
|
{"/search", "/v1/search"},
|
|
{"", ""},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.input, func(t *testing.T) {
|
|
got := normalizeAPIPath(tt.input)
|
|
if got != tt.want {
|
|
t.Errorf("normalizeAPIPath(%q) = %q, want %q", tt.input, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|