| index b5b3e7656..1976dc358 100644 |
| --- a/internal/console/apiship_swap_test.go |
| +++ b/internal/console/apiship_swap_test.go |
| @@ -70,3 +70,29 @@ func TestAPIShipWithoutSwapAnswersAsBefore(t *testing.T) { |
| t.Fatalf("a ship with no demand echoes swap: %v", out) |
| } |
| } |
| + |
| +func TestAPIShipRefusesAddingTheDemandOnAReship(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + liftShipBudget(fx) |
| + token := cliToken(t, fx, "paul@keymail.dev", "code-ship-swap-add") |
| + u := fx.ts.URL + "/api/cli/apps/" + fx.sqid + "/kass/releases" |
| + art := shipPart{name: "linux-arm64", body: randomBytes(t, 64)} |
| + |
| + if code, out := postShip(t, u, token, []shipPart{metaPart(t, "v12", "binary"), art}); code != http.StatusCreated { |
| + t.Fatalf("ship = %d %v", code, out) |
| + } |
| + code, out := postShip(t, u, token, []shipPart{metaPart(t, "v12", "binary"), art}) |
| + if code != http.StatusOK { |
| + t.Fatalf("identical no-demand re-ship = %d %v, want 200", code, out) |
| + } |
| + if _, present := out["swap"]; present { |
| + t.Fatalf("a re-ship with no demand echoes swap: %v", out) |
| + } |
| + if code, out = postShip(t, u, token, []shipPart{metaPartSwap(t, "v12", "hold"), art}); code != http.StatusConflict { |
| + t.Fatalf("re-ship adding the demand = %d %v, want 409", code, out) |
| + } |
| + m, err := release.GetManifest(context.Background(), fx.rel, fx.sqid, "kass", "v12") |
| + if err != nil || m.Swap != "" { |
| + t.Fatalf("stored manifest swap = %q, %v, want it unchanged", m.Swap, err) |
| + } |
| +} |