chore: 并入 iotlcm-admin-svr 历史到 admin-svr/(原提交 49818c6)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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")
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user