Files
audita/internal/core/glossary/vocabulary_test.go

31 lines
1.0 KiB
Go

package glossary
import (
"reflect"
"testing"
)
func TestVocabularyKeepsContributorsAndExemptsOnlyActiveSpellings(t *testing.T) {
plural := "Aegides"
active := []Entry{{Collection: "spells", ID: "shield", Name: "Shield", Aliases: []string{"Ward"}}}
protected := []Entry{
active[0],
{Collection: "items", ID: "shield", Name: "shield", Aliases: []string{"Aegis"}, Plural: &plural},
}
full := Vocabulary(protected, nil)
if !reflect.DeepEqual(full[0].Identities, []Identity{{Collection: "spells", ID: "shield"}, {Collection: "items", ID: "shield"}}) {
t.Fatalf("shared spelling contributors: %+v", full[0])
}
reduced := Vocabulary(protected, active)
var got []string
for _, term := range reduced {
got = append(got, term.Spelling)
}
if !reflect.DeepEqual(got, []string{"Aegis", "Aegiss", "Aegides"}) {
t.Fatalf("remaining spellings: %v", got)
}
if !reflect.DeepEqual(full, Vocabulary(protected, nil)) || protected[0].Aliases[0] != "Ward" {
t.Fatal("deriving an exemption changed another view or its inputs")
}
}