Files
iotlcm/server/internal/logic/app/app_lifecycle_metadata_test.go
T

34 lines
1.3 KiB
Go

package app
import (
"testing"
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/batchmetadata"
)
func TestLifecycleExecutionModeUsesRequestShape(t *testing.T) {
tests := []struct {
name string
cardValue string
cardValues []string
wantMode int
wantCount int
wantError bool
}{
{name: "single", cardValue: "card1", wantMode: batchmetadata.Single, wantCount: 1},
{name: "bulk with one card", cardValues: []string{"card1"}, wantMode: batchmetadata.Bulk, wantCount: 1},
{name: "bulk deduplicated to one", cardValues: []string{"card1", "card1"}, wantMode: batchmetadata.Bulk, wantCount: 1},
{name: "multiple cards in single input", cardValue: "card1,card2", wantMode: batchmetadata.Single, wantError: true},
{name: "multiple lines in single input", cardValue: "card1\ncard2", wantMode: batchmetadata.Single, wantError: true},
{name: "bulk input", cardValues: []string{"card1,card2"}, wantMode: batchmetadata.Bulk, wantCount: 2},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
values, mode, err := appNormalizeLifecycleCardValues(test.cardValue, test.cardValues)
if (err != nil) != test.wantError || mode != test.wantMode || len(values) != test.wantCount {
t.Fatalf("values=%v mode=%d err=%v", values, mode, err)
}
})
}
}