Files
geo/server/internal/tenant/app/publish_job_service_test.go
T

64 lines
1.1 KiB
Go
Raw Normal View History

package app
import "testing"
func TestResolveRetryArticleIDFromPayload(t *testing.T) {
t.Parallel()
cases := []struct {
name string
payload map[string]any
wantID int64
wantOK bool
}{
{
name: "top level article id",
payload: map[string]any{
"article_id": 78,
},
wantID: 78,
wantOK: true,
},
{
name: "nested content ref article id",
payload: map[string]any{
"content_ref": map[string]any{
"article_id": 79,
},
},
wantID: 79,
wantOK: true,
},
{
name: "nested content ref generic id",
payload: map[string]any{
"content_ref": map[string]any{
"id": 80,
},
},
wantID: 80,
wantOK: true,
},
{
name: "missing article id",
payload: map[string]any{
"publish_record_id": 999,
},
wantID: 0,
wantOK: false,
},
}
for _, tc := range cases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
gotID, gotOK := resolveRetryArticleIDFromPayload(tc.payload)
if gotID != tc.wantID || gotOK != tc.wantOK {
t.Fatalf("resolveRetryArticleIDFromPayload() = (%d, %v), want (%d, %v)", gotID, gotOK, tc.wantID, tc.wantOK)
}
})
}
}