Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions e2e/harness/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestParseActOutput(t *testing.T) {

if result.Jobs["build-app"] == nil {
t.Fatal("expected build-app job in result")
return
}
if result.Jobs["build-app"].Conclusion != "success" {
t.Errorf("expected build-app conclusion=success, got %s", result.Jobs["build-app"].Conclusion)
Expand All @@ -32,6 +33,7 @@ func TestParseActOutput(t *testing.T) {
}
if result.Jobs["deploy-cdk"] == nil {
t.Fatal("expected deploy-cdk job in result")
return
}
if result.Jobs["deploy-cdk"].Conclusion != "skipped" {
t.Errorf("expected deploy-cdk conclusion=skipped, got %s", result.Jobs["deploy-cdk"].Conclusion)
Expand Down
1 change: 1 addition & 0 deletions e2e/harness/scenario_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func TestRunScenarioWithRetry_PersistsEvidenceOnExhaustion(t *testing.T) {
})
if err == nil {
t.Fatal("expected an error after exhausting attempts")
return
}

// The error must reference a written artifact path.
Expand Down
7 changes: 7 additions & 0 deletions internal/config/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func TestParse(t *testing.T) {
// Verify validate config
if cfg.Validate == nil {
t.Fatal("Validate is nil")
return
}
if cfg.Validate.Workflow != ".github/workflows/validate.yaml" {
t.Errorf("Validate.Workflow = %q, want %q", cfg.Validate.Workflow, ".github/workflows/validate.yaml")
Expand Down Expand Up @@ -143,6 +144,7 @@ func TestParse_WithInputs(t *testing.T) {
// Verify build inputs
if cfg.Builds[0].Inputs == nil {
t.Fatal("Builds[0].Inputs is nil")
return
}
if cfg.Builds[0].Inputs["dockerfile_path"] != "./src/Dockerfile" {
t.Errorf("Builds[0].Inputs[dockerfile_path] = %v, want ./src/Dockerfile", cfg.Builds[0].Inputs["dockerfile_path"])
Expand All @@ -154,6 +156,7 @@ func TestParse_WithInputs(t *testing.T) {
// Verify deploy inputs
if cfg.Deploys[0].Inputs == nil {
t.Fatal("Deploys[0].Inputs is nil")
return
}
if cfg.Deploys[0].Inputs["cluster_name"] != "my-cluster" {
t.Errorf("Deploys[0].Inputs[cluster_name] = %v, want my-cluster", cfg.Deploys[0].Inputs["cluster_name"])
Expand All @@ -162,6 +165,7 @@ func TestParse_WithInputs(t *testing.T) {
// Verify env_inputs
if cfg.Deploys[0].EnvInputs == nil {
t.Fatal("Deploys[0].EnvInputs is nil")
return
}
if cfg.Deploys[0].EnvInputs["dev"]["replicas"] != 1 {
t.Errorf("Deploys[0].EnvInputs[dev][replicas] = %v, want 1", cfg.Deploys[0].EnvInputs["dev"]["replicas"])
Expand Down Expand Up @@ -499,6 +503,7 @@ func TestParse_ReleaseAndChangelogConfig(t *testing.T) {
// Release config
if cfg.Release == nil {
t.Fatal("Release is nil")
return
}
if cfg.Release.Disabled {
t.Error("Release.Disabled should be false (enabled by default)")
Expand All @@ -510,6 +515,7 @@ func TestParse_ReleaseAndChangelogConfig(t *testing.T) {
// Changelog config
if cfg.Changelog == nil {
t.Fatal("Changelog is nil")
return
}
if cfg.Changelog.Workflow != ".github/workflows/custom-changelog.yaml" {
t.Errorf("Changelog.Workflow = %q, want .github/workflows/custom-changelog.yaml", cfg.Changelog.Workflow)
Expand Down Expand Up @@ -544,6 +550,7 @@ func TestParse_ReleaseDisabled(t *testing.T) {

if cfg.Release == nil {
t.Fatal("Release is nil")
return
}
if !cfg.Release.Disabled {
t.Error("Release.Disabled should be true")
Expand Down
1 change: 1 addition & 0 deletions internal/config/schema_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ components:
`)
if cfg.Components == nil {
t.Fatal("Components map should be parsed")
return
}
if cfg.Components["api"].Path != "services/api" {
t.Fatalf("unexpected path: %q", cfg.Components["api"].Path)
Expand Down
2 changes: 2 additions & 0 deletions internal/config/schema_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func TestValidateSchemaVersionHelper(t *testing.T) {
if tt.wantErr {
if err == nil {
t.Fatalf("expected error, got nil (warn=%q)", warn)
return
}
if tt.errContains != "" && !strings.Contains(err.Error(), tt.errContains) {
t.Fatalf("error %q does not contain %q", err.Error(), tt.errContains)
Expand Down Expand Up @@ -163,6 +164,7 @@ func TestValidateSchemaVersion(t *testing.T) {
if tt.wantFatal {
if fatalErr == nil {
t.Fatalf("expected fatal error, got nil")
return
}
if tt.errContains != "" && !strings.Contains(fatalErr.Error(), tt.errContains) {
t.Fatalf("error %q does not contain %q", fatalErr.Error(), tt.errContains)
Expand Down
2 changes: 2 additions & 0 deletions internal/config/validate_telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,14 @@ telemetry:
`)
if cfg.Telemetry == nil {
t.Fatalf("telemetry block did not parse")
return
}
if !cfg.Telemetry.Enabled || cfg.Telemetry.Adapter != TelemetryAdapterNone {
t.Fatalf("telemetry enabled/adapter: %#v", cfg.Telemetry)
}
if cfg.Telemetry.Webhook == nil {
t.Fatalf("telemetry.webhook did not parse")
return
}
if cfg.Telemetry.Webhook.URL != "https://metrics.example.com/ingest" {
t.Fatalf("telemetry.webhook.url: %q", cfg.Telemetry.Webhook.URL)
Expand Down
3 changes: 3 additions & 0 deletions internal/config/validate_versionoverrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ release:
`)
if cfg.Release == nil {
t.Fatalf("release block did not parse")
return
}
if cfg.Release.VersionOverrides == nil {
t.Fatalf("release.version_overrides did not parse")
return
}
if got := cfg.Release.VersionOverrides.Dir; got != ".cascade/version-overrides" {
t.Fatalf("release.version_overrides.dir = %q", got)
Expand Down Expand Up @@ -121,6 +123,7 @@ release:
`)
if cfg.Release == nil {
t.Fatalf("release block did not parse")
return
}
if cfg.Release.VersionOverrides != nil {
t.Fatalf("version_overrides should be nil when absent, got %#v", cfg.Release.VersionOverrides)
Expand Down
2 changes: 2 additions & 0 deletions internal/hotfix/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ func TestPlanChain_RejectsNonTrunkCommit(t *testing.T) {
_, err := p.PlanChain([]string{fix1, side}, "test")
if err == nil {
t.Fatal("expected error citing the non-trunk ref")
return
}
if !strings.Contains(err.Error(), "trunk") {
t.Errorf("error %q should mention trunk", err.Error())
Expand Down Expand Up @@ -396,6 +397,7 @@ func TestPlanChain_RemoteEnvTipDiverged_FailsWithGuidance(t *testing.T) {
_, err := p.PlanChain([]string{fix}, "test")
if err == nil {
t.Fatal("expected divergence error when remote env tip differs from recorded state SHA")
return
}
msg := err.Error()
if !strings.Contains(msg, "env/test") {
Expand Down
2 changes: 2 additions & 0 deletions internal/hotfix/finalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ func TestFinalize_MergeSHATipMismatch_Fails(t *testing.T) {
err := f.Finalize("test", other, []string{fix}, base)
if err == nil {
t.Fatal("expected mismatch error when merge SHA is not env/test tip")
return
}
if !strings.Contains(strings.ToLower(err.Error()), "tip") {
t.Errorf("error %q should mention the branch tip mismatch", err.Error())
Expand Down Expand Up @@ -773,6 +774,7 @@ func TestFinalize_TrunkStateAbsent_Errors(t *testing.T) {
err := f.Finalize("test", merge, []string{fix}, base)
if err == nil {
t.Fatal("expected missing-state error when trunk has no recorded SHA for the target env")
return
}
if !strings.Contains(err.Error(), "no recorded state SHA") {
t.Errorf("error %q should report the missing recorded state SHA", err.Error())
Expand Down
4 changes: 4 additions & 0 deletions internal/hotfix/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func TestPlan_RejectsNonTrunkCommit(t *testing.T) {
_, err := p.Plan(side, "test")
if err == nil {
t.Fatal("expected error for non-trunk commit, got nil")
return
}
if !strings.Contains(err.Error(), "trunk") {
t.Errorf("error %q should mention trunk", err.Error())
Expand All @@ -150,6 +151,7 @@ func TestPlan_RejectsFirstEnv(t *testing.T) {
_, err := p.Plan(fix, "dev")
if err == nil {
t.Fatal("expected error for first env, got nil")
return
}
if !strings.Contains(err.Error(), "first environment") {
t.Errorf("error %q should mention first environment", err.Error())
Expand Down Expand Up @@ -277,6 +279,7 @@ func TestPlan_ExistingBranchTipMismatch_FailsClosedWithoutRealChecker(t *testing
_, err := p.Plan(fix, "test")
if err == nil {
t.Fatal("expected tip-mismatch error")
return
}
msg := err.Error()
if !strings.Contains(msg, "abandoned hotfix branch") {
Expand Down Expand Up @@ -325,6 +328,7 @@ func TestPlan_SingleFlight_OpenPRBlocks(t *testing.T) {
_, err := p.Plan(fix, "test")
if err == nil {
t.Fatal("expected single-flight error")
return
}
if checker.calledWith != "env/test" {
t.Errorf("PR checker queried %q, want env/test", checker.calledWith)
Expand Down
1 change: 1 addition & 0 deletions internal/hotfix/pr_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func TestRestPRChecker_NonOKResponseReturnsError(t *testing.T) {
_, err := c.OpenHotfixPRs("env/test")
if err == nil {
t.Fatal("expected an error for a non-200 response, got nil")
return
}
if !strings.Contains(err.Error(), "404") {
t.Errorf("error %q should reference the HTTP status code", err.Error())
Expand Down
7 changes: 7 additions & 0 deletions internal/hotfix/selfheal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func TestReconcileBranch_NotCheckedFailsClosedNoReset(t *testing.T) {
created, reset, err := p.reconcileBranch("env/test", "basesha", false /*diverged*/, false /*singleFlightChecked*/)
if err == nil {
t.Fatal("expected fail-closed divergence error, got nil")
return
}
if created || reset {
t.Errorf("created=%v reset=%v, both must be false when failing closed", created, reset)
Expand All @@ -142,6 +143,7 @@ func TestReconcileBranch_DivergedFailsClosedNoReset(t *testing.T) {
created, reset, err := p.reconcileBranch("env/test", "basesha", true /*diverged*/, true /*singleFlightChecked*/)
if err == nil {
t.Fatal("expected fail-closed divergence error, got nil")
return
}
if created || reset {
t.Errorf("created=%v reset=%v, both must be false when failing closed", created, reset)
Expand Down Expand Up @@ -179,6 +181,7 @@ func TestReconcileBranch_SelfHealReportsResetError(t *testing.T) {
_, _, err := p.reconcileBranch("env/test", "basesha", false, true)
if err == nil {
t.Fatal("expected the ResetBranch failure to surface")
return
}
if !strings.Contains(err.Error(), "self-healing orphan") {
t.Errorf("error %q should wrap the self-heal failure", err.Error())
Expand Down Expand Up @@ -226,6 +229,7 @@ func TestVerifyRemoteEnvTip_DivergedFailsClosedNoReset(t *testing.T) {
reset, err := p.verifyRemoteEnvTip("env/test", "basesha", true /*diverged*/, true)
if err == nil {
t.Fatal("expected fail-closed divergence error, got nil")
return
}
if reset {
t.Error("reset must be false for a diverged env")
Expand Down Expand Up @@ -317,6 +321,7 @@ func TestPlanChain_OrphanRemoteTipNoopCheckerFailsClosed(t *testing.T) {
_, err := p.PlanChain([]string{fix}, "test")
if err == nil {
t.Fatal("expected fail-closed divergence error without a real checker")
return
}
if len(rr.resets) != 0 {
t.Fatalf("ResetBranch must NOT be called without a real single-flight check, got %d", len(rr.resets))
Expand Down Expand Up @@ -355,6 +360,7 @@ func TestPlanChain_AbortsOnOpenConflictPR(t *testing.T) {
_, err := p.PlanChain([]string{fix}, "test")
if err == nil {
t.Fatal("expected single-flight abort when a conflict-resolution hotfix PR is open")
return
}
if !strings.Contains(err.Error(), "55") {
t.Errorf("error %q should reference the open PR number", err.Error())
Expand Down Expand Up @@ -388,6 +394,7 @@ func TestPlanChain_AbortsOnOpenHotfixPR(t *testing.T) {
_, err := p.PlanChain([]string{fix}, "test")
if err == nil {
t.Fatal("expected single-flight abort when a hotfix PR is open")
return
}
if !strings.Contains(err.Error(), "77") {
t.Errorf("error %q should reference the open PR number", err.Error())
Expand Down
2 changes: 2 additions & 0 deletions internal/orchestrate/nochange_skip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ func TestFinalize_RecordsPerBuildSHA(t *testing.T) {
envState := orch.cicdFile.State["prerelease"]
if envState == nil {
t.Fatalf("prerelease state is nil after Finalize")
return
}
bs := envState.Builds["app"]
if bs == nil {
t.Fatalf("envState.Builds[app] is nil; expected a recorded build state")
return
}
if bs.SHA != headSHA {
t.Errorf("envState.Builds[app].SHA = %q, want %q", bs.SHA, headSHA)
Expand Down
1 change: 1 addition & 0 deletions internal/promote/guards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func TestPromote_IntoDivergedEnv_MissingPatch_Blocked(t *testing.T) {
_, err := pf.Run()
if err == nil {
t.Fatalf("expected preflight to block promotion into diverged env missing a patch")
return
}
if !containsAllOf(err.Error(), "patchsha1") {
t.Errorf("error should name the missing patch, got: %q", err.Error())
Expand Down
2 changes: 2 additions & 0 deletions internal/promote/promote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ func TestDefaultPromotion_StripsRCSuffixOnPublishEnv(t *testing.T) {
}
if releasePromo == nil {
t.Fatal("no promotion found for env 'release'")
return
}

if releasePromo.Version != "v1.0.0" {
Expand Down Expand Up @@ -404,6 +405,7 @@ func TestCascadePromotion_StripsRCSuffixOnPublishEnv(t *testing.T) {
}
if releasePromo == nil {
t.Fatal("no promotion found for env 'release'")
return
}

if releasePromo.Version != "v1.0.0" {
Expand Down
1 change: 1 addition & 0 deletions internal/promote/save_config_preserve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func TestSaveConfig_NonDryRunPromote_PreservesUnmodeledManifestKeys(t *testing.T
testState := reparsed.State["test"]
if testState == nil {
t.Fatalf("expected state.test to be written, got nil; manifest:\n%s", out)
return
}
if testState.SHA != "abc123" {
t.Errorf("state.test.sha = %q, want %q", testState.SHA, "abc123")
Expand Down
5 changes: 5 additions & 0 deletions internal/release/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func TestNewCommand_TagOnlyFlag(t *testing.T) {
flag := cmd.Flags().Lookup("tag-only")
if flag == nil {
t.Fatal("expected --tag-only flag to be registered on manage-release")
return
}
if flag.DefValue != "false" {
t.Errorf("--tag-only default = %q, want false", flag.DefValue)
Expand Down Expand Up @@ -98,6 +99,7 @@ func TestValidateManageReleaseFlags_SHARequiredOnlyForTagCreatingActions(t *test
if tt.wantErr {
if err == nil {
t.Fatalf("expected error for action %q with sha=%q, got nil", tt.action, tt.sha)
return
}
if tt.errSubstr != "" && !strings.Contains(err.Error(), tt.errSubstr) {
t.Fatalf("expected error containing %q, got %q", tt.errSubstr, err.Error())
Expand Down Expand Up @@ -132,6 +134,7 @@ func TestValidateManageReleaseFlags_OtherRequiredFields(t *testing.T) {
err := validateManageReleaseFlags(ActionLock, tt.repo, tt.env, "", tt.tag)
if err == nil {
t.Fatalf("expected error, got nil")
return
}
if !strings.Contains(err.Error(), tt.errSubstr) {
t.Fatalf("expected error containing %q, got %q", tt.errSubstr, err.Error())
Expand Down Expand Up @@ -166,6 +169,7 @@ func TestComponentReapOptions_ComponentRequiresConfig(t *testing.T) {
_, err := componentReapOptions("", "ci", "api")
if err == nil {
t.Fatal("expected an error when --component is set without --config")
return
}
if !strings.Contains(err.Error(), "--config is required") {
t.Fatalf("expected a --config-required error, got %q", err.Error())
Expand Down Expand Up @@ -205,6 +209,7 @@ func TestComponentReapOptions_ThreadsStrictComponentGrammar(t *testing.T) {
mgr := NewManager("owner/repo", "tok", opts...)
if mgr.grammar == nil {
t.Fatal("expected a threaded component grammar, got nil")
return
}
if got := mgr.grammar.Prefix; got != "api-" {
t.Errorf("grammar prefix = %q, want api-", got)
Expand Down
5 changes: 5 additions & 0 deletions internal/rollback/command_subcommands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ func TestRollbackFinalize_SkippedDeployableNotCounted(t *testing.T) {
prod := file.State["prod"]
if prod == nil {
t.Fatal("prod state missing after finalize")
return
}
// A deployable-scoped rollback re-applies the per-deployable SHA without
// touching the env-level pointer. With "services" succeeding and "web-api"
Expand All @@ -247,6 +248,7 @@ func TestRollbackFinalize_SkippedDeployableNotCounted(t *testing.T) {
ds := prod.Deploys["services"]
if ds == nil {
t.Fatal("services deploy state missing after finalize")
return
}
if ds.SHA != "prodold1112223" {
t.Errorf("services sha = %q, want prodold1112223", ds.SHA)
Expand Down Expand Up @@ -281,6 +283,7 @@ func TestRollbackFinalize_AppliesWhenDeploySucceeded(t *testing.T) {
prod := file.State["prod"]
if prod == nil {
t.Fatal("prod state missing after finalize")
return
}
if prod.SHA != "prodold1112223" {
t.Errorf("env sha = %q, want prodold1112223", prod.SHA)
Expand Down Expand Up @@ -319,6 +322,7 @@ func TestRollbackFinalize_AbortsWhenDeployFailed(t *testing.T) {
err = cmd.Execute()
if err == nil {
t.Fatal("expected error when a deploy failed, got nil")
return
}
if !strings.Contains(err.Error(), "services") || !strings.Contains(err.Error(), "did not succeed") {
t.Errorf("error %q should name the failed deploy and say it did not succeed", err.Error())
Expand Down Expand Up @@ -389,6 +393,7 @@ func TestRollbackFinalize_NoDeploysConfigured_StillApplies(t *testing.T) {
prod := file.State["prod"]
if prod == nil {
t.Fatal("prod state missing after finalize")
return
}
if prod.SHA != "prodold1112223" {
t.Errorf("env sha = %q, want prodold1112223", prod.SHA)
Expand Down
Loading