Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoadFixture(t *testing.T) {
|
||||
fx, err := loadFixture("testdata/fixture.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(fx.Companies) != 1 || len(fx.Users) != 2 {
|
||||
t.Fatalf("unexpected fixture sizes: companies=%d users=%d", len(fx.Companies), len(fx.Users))
|
||||
}
|
||||
if len(fx.AdminUsers) != 1 {
|
||||
t.Fatalf("expected admin_users")
|
||||
}
|
||||
if len(fx.XMLFeeds) != 1 || len(fx.XMLFeeds[0].FieldMappings) == 0 {
|
||||
t.Fatalf("expected feed mappings in fixture")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnsureJSON(t *testing.T) {
|
||||
if string(ensureJSON(nil)) != "{}" {
|
||||
t.Fatalf("nil -> {}")
|
||||
}
|
||||
if string(ensureJSON([]byte("not-json"))) != "{}" {
|
||||
t.Fatalf("invalid -> {}")
|
||||
}
|
||||
in := []byte(`{"a":1}`)
|
||||
if string(ensureJSON(in)) != `{"a":1}` {
|
||||
t.Fatalf("valid passthrough")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAttachEntityMaps(t *testing.T) {
|
||||
doc := NewIDMapDocument(map[string]string{"u1": "550e8400-e29b-41d4-a716-446655440000"}, map[string]string{"c1": "6ba7b810-9dad-11d1-80b4-00c04fd430c8"}, true)
|
||||
doc.AttachEntityMaps(nil, nil, map[string]string{"10": "6ba7b810-9dad-11d1-80b4-00c04fd430c8"}, nil, nil, map[string]int{"feeds": 1})
|
||||
if len(doc.Feeds) != 1 || doc.Meta.Report["feeds"] != 1 {
|
||||
t.Fatalf("attach failed: %#v", doc)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user