Skip to content

Commit bae62a5

Browse files
committed
chore: Add tests for getExecutionOrderPatch func
Signed-off-by: Zaki Shaikh <[email protected]> Assisted-by: Claude-4-Sonnet (via Cursor)
1 parent 6b55d0e commit bae62a5

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

pkg/pipelineascode/pipelineascode_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,3 +750,40 @@ func TestGetLogURLMergePatch(t *testing.T) {
750750
assert.Assert(t, ok)
751751
assert.Equal(t, a[path.Join(apipac.GroupName, "log-url")], con.URL())
752752
}
753+
754+
func TestGetExecutionOrderPatch(t *testing.T) {
755+
tests := []struct {
756+
name string
757+
order string
758+
want string
759+
}{
760+
{
761+
name: "single pr",
762+
order: "pull-pr-1",
763+
want: "pull-pr-1",
764+
},
765+
{
766+
name: "multiple prs",
767+
order: "pull-pr-1,pull-pr-2,pull-pr-3",
768+
want: "pull-pr-1,pull-pr-2,pull-pr-3",
769+
},
770+
{
771+
name: "empty",
772+
order: "",
773+
want: "",
774+
},
775+
}
776+
777+
for _, tt := range tests {
778+
t.Run(tt.name, func(t *testing.T) {
779+
result := getExecutionOrderPatch(tt.order)
780+
m, ok := result["metadata"].(map[string]any)
781+
assert.Assert(t, ok, "metadata should be present in result")
782+
783+
anns, ok := m["annotations"].(map[string]string)
784+
assert.Assert(t, ok, "annotations should be present in metadata")
785+
786+
assert.Equal(t, anns[keys.ExecutionOrder], tt.want, "execution order should match")
787+
})
788+
}
789+
}

0 commit comments

Comments
 (0)