Commit ec1bb91
committed
refactor: port status page migrate commands to SDK + RunContext
Replaces the CLI-local raw-HTTP transport introduced by #1 with the
flashduty-sdk v0.7.0 methods and routes the 4 migrate subcommands
through the RunContext / runCommand pattern used by every other
command.
Changes:
- Bump flashduty-sdk from v0.6.0 to v0.7.0 (adds status page migration
methods).
- Extend flashdutyClient interface with StartStatusPageMigration,
StartStatusPageEmailSubscriberMigration, GetStatusPageMigrationStatus,
CancelStatusPageMigration.
- Add default mockClient stubs for the four new interface methods.
- Rewrite internal/cli/status_page_migrate.go (~590 lines to ~280):
delete statusPageMigrationAPI, statusPageMigrationService, the
CLI-local migration transport, manual sanitization, and duplicate
local types. Each cobra command now uses runCommand(cmd, args,
func(ctx *RunContext) error {...}) and delegates to ctx.Client.*.
Print helpers rewired from flagJSON / newPrinter() globals to
ctx.JSON / ctx.Printer / ctx.Writer.
- Rewrite internal/cli/status_page_migrate_test.go (387 lines to ~340):
replace httptest-backed transport tests with newClientFn mock-swap
tests using execCommand, matching the pattern established in
command_test.go. One httptest-backed integration test per SDK method
is not kept here because the flashduty-sdk repo owns wire-format
tests now.
Post-review fixes (independent reviews from go-reviewer + Codex):
- Nil-guard mock methods so tests overriding a subset do not panic.
- Assert "atlassian" substring in the unsupported-source error so the
supported list cannot silently drift.
- Emit both "command" (PR #1 schema) and "next_command" in cancel
--json output to preserve the shipped JSON contract.
- Move validateMigrationSource before runCommand so an invalid --from
fails with the source error before any client/auth work, matching
PR #1 ordering. Add two tests locking the ordering.
Command output and JSON schemas remain compatible with PR #1. The
file internal/cli/status_page_migrate.go is no longer an architectural
outlier: 100% of the CLI now flows through ctx.Client.
Verification:
- go test -race -count=1 ./... green
- go test -tags=e2e ./e2e/... green (24.4s)
- gofmt, goimports, go vet clean
- Coverage on ported commands: 80-100%.1 parent bf81170 commit ec1bb91
6 files changed
Lines changed: 401 additions & 661 deletions
File tree
- internal/cli
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
194 | 210 | | |
195 | 211 | | |
196 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
71 | 77 | | |
72 | 78 | | |
73 | 79 | | |
| |||
0 commit comments