test(postgres): check the stored phase of a backup job per cnpg Backup phase

The phase test read the BackupJob it passed to the reconciler, which
holds the phase in memory whether or not the status write happened. A
completed Backup could then leave the stored BackupJob Running, so the
Plan would never see the run finish, and no test in the package noticed.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
This commit is contained in:
Alexey Artamonov committed 2026-11-09 23:52:25 +03:00
1 parent 93c3ee62c4
commit 7efe33e87d
1 file changed
+7
@@ -2421,6 +2421,13 @@ func TestReconcileCNPG_BackupPhaseOutcome(t *testing.T) {
if j.Status.Phase != tc.wantPhase {
t.Fatalf("BackupJob phase = %q (%s), want %q", j.Status.Phase, j.Status.Message, tc.wantPhase)
}
stored := &backupsv1alpha1.BackupJob{}
if err := c.Get(context.Background(), client.ObjectKeyFromObject(job), stored); err != nil {
t.Fatalf("get BackupJob after reconcile: %v", err)
}
if stored.Status.Phase != tc.wantPhase {
t.Fatalf("stored BackupJob phase = %q, want %q", stored.Status.Phase, tc.wantPhase)
}
message := j.Status.Message
if tc.wantPhase == backupsv1alpha1.BackupJobPhaseRunning {