44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestCardValidationRemainsEnabled(t *testing.T) {
|
|
for _, items := range [][]string{nil, {"simStatus"}} {
|
|
in := &TSimChannelsTestParam{ChannelId: 42, InputMode: TSimChannelsTestInputModeDirectSingle, Items: items}
|
|
if err := in.Filter(context.Background()); err == nil {
|
|
t.Fatalf("card validation must remain enabled for %v", items)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestNormalizeTSimChannelTestItems(t *testing.T) {
|
|
t.Run("empty selects all items", func(t *testing.T) {
|
|
items, err := NormalizeTSimChannelTestItems(nil)
|
|
if err != nil {
|
|
t.Fatalf("NormalizeTSimChannelTestItems returned error: %v", err)
|
|
}
|
|
if items != nil {
|
|
t.Fatalf("expected nil items, got %#v", items)
|
|
}
|
|
})
|
|
|
|
t.Run("trims and deduplicates requested items", func(t *testing.T) {
|
|
items, err := NormalizeTSimChannelTestItems([]string{" simBasicInfo ", "simSession", "simBasicInfo"})
|
|
if err != nil {
|
|
t.Fatalf("NormalizeTSimChannelTestItems returned error: %v", err)
|
|
}
|
|
if len(items) != 2 || items[0] != "simBasicInfo" || items[1] != "simSession" {
|
|
t.Fatalf("unexpected normalized items: %#v", items)
|
|
}
|
|
})
|
|
|
|
t.Run("rejects unknown items", func(t *testing.T) {
|
|
if _, err := NormalizeTSimChannelTestItems([]string{"unknown"}); err == nil {
|
|
t.Fatal("expected an error for an unknown item")
|
|
}
|
|
})
|
|
}
|