package store import "testing" func TestNormalizeDohProfileIDList(t *testing.T) { got := NormalizeDohProfileIDList([]string{" a ", "b", "a", "", "b"}) if len(got) != 2 || got[0] != "a" || got[1] != "b" { t.Fatalf("unexpected: %v", got) } } func TestApplyModuleDohPatch(t *testing.T) { mod := &Module{DohProfileIDs: []string{"one"}, DohResolverPolicy: DohPolicyPrimaryOnly} ids := []string{"ru", "eu"} policy := DohPolicyUnion ApplyModuleDohPatch(mod, &ModulePatch{DohProfileIDs: &ids, DohResolverPolicy: &policy}) if len(mod.DohProfileIDs) != 2 || mod.DohResolverPolicy != DohPolicyUnion { t.Fatalf("unexpected module doh fields: %+v", mod) } if mod.DohProfileID == nil || *mod.DohProfileID != "ru" { t.Fatalf("legacy id not synced: %+v", mod.DohProfileID) } } func TestEffectiveDohProfileIDs_LegacyField(t *testing.T) { id := "legacy-id" mod := &Module{DohProfileID: &id} got := mod.EffectiveDohProfileIDs() if len(got) != 1 || got[0] != "legacy-id" { t.Fatalf("unexpected: %v", got) } }