Skip to content

Commit 2050ab3

Browse files
committed
fix: Test actual upsert
Signed-off-by: Zach Aller <[email protected]>
1 parent b24bc90 commit 2050ab3

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

internal/utils/utils_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,54 @@ func TestUpsertEnvironmentStatus(t *testing.T) {
5757
insert: promoterv1alpha1.EnvironmentStatus{Branch: "dev"},
5858
expected: []promoterv1alpha1.EnvironmentStatus{{Branch: "main"}, {Branch: "dev"}},
5959
},
60+
{
61+
name: "Update existing element",
62+
initial: []promoterv1alpha1.EnvironmentStatus{{
63+
Branch: "main",
64+
Active: promoterv1alpha1.PromotionStrategyBranchStateStatus{
65+
Dry: promoterv1alpha1.CommitShaState{
66+
Sha: "old",
67+
},
68+
Hydrated: promoterv1alpha1.CommitShaState{
69+
Sha: "old",
70+
},
71+
CommitStatus: promoterv1alpha1.PromotionStrategyCommitStatus{
72+
Sha: "old",
73+
Phase: "pending",
74+
},
75+
},
76+
}},
77+
insert: promoterv1alpha1.EnvironmentStatus{
78+
Branch: "main",
79+
Active: promoterv1alpha1.PromotionStrategyBranchStateStatus{
80+
Dry: promoterv1alpha1.CommitShaState{
81+
Sha: "new",
82+
},
83+
Hydrated: promoterv1alpha1.CommitShaState{
84+
Sha: "new",
85+
},
86+
CommitStatus: promoterv1alpha1.PromotionStrategyCommitStatus{
87+
Sha: "new",
88+
Phase: "success",
89+
},
90+
},
91+
},
92+
expected: []promoterv1alpha1.EnvironmentStatus{{
93+
Branch: "main",
94+
Active: promoterv1alpha1.PromotionStrategyBranchStateStatus{
95+
Dry: promoterv1alpha1.CommitShaState{
96+
Sha: "new",
97+
},
98+
Hydrated: promoterv1alpha1.CommitShaState{
99+
Sha: "new",
100+
},
101+
CommitStatus: promoterv1alpha1.PromotionStrategyCommitStatus{
102+
Sha: "new",
103+
Phase: "success",
104+
},
105+
},
106+
}},
107+
},
60108
}
61109

62110
for _, test := range tests {

0 commit comments

Comments
 (0)