clone

an offline map explorer where each world, from a game map to a city's open data, ships as one .atlas file

main
atlas / internal / generate / sources / sources_test.go
sources_test.go 1.5K
1package sources23import (4 "strings"5 "testing"67 "github.com/FelineStateMachine/atlas/internal/generate/doc"8)910// TestRegistryIsComplete holds every registered source to what a document, a11// ledger and a source card need from it. A source that cannot say who it is12// produces documents nothing downstream can attribute.13func TestRegistryIsComplete(t *testing.T) {14 seen := map[string]bool{}15 for _, source := range All() {16 about := source.Describe()17 t.Run(about.Name, func(t *testing.T) {18 if about.Name == "" {19 t.Fatal("a source with no name")20 }21 if seen[about.Name] {22 t.Fatalf("two sources are registered as %q", about.Name)23 }24 seen[about.Name] = true25 if about.Label == "" {26 t.Error("no label for a person to read")27 }28 if about.Attribution == "" && about.License == "" {29 t.Error("neither a licence nor an attribution; a volume owes the people whose work it carries")30 }31 switch about.IDSpace {32 case doc.IDSpaceNative, doc.IDSpaceDerived:33 default:34 t.Errorf("id space %q is neither %q nor %q",35 about.IDSpace, doc.IDSpaceNative, doc.IDSpaceDerived)36 }37 if strings.ToLower(about.Name) != about.Name {38 t.Errorf("name %q is not a slug", about.Name)39 }40 })41 }42 if len(seen) == 0 {43 t.Fatal("no source is registered")44 }45}4647func TestFor(t *testing.T) {48 for _, name := range Names() {49 if _, err := For(name); err != nil {50 t.Errorf("For(%q): %v", name, err)51 }52 }53 if _, err := For("nobody"); err == nil {54 t.Error("an unregistered source answered")55 }56}