MCPcopy Create free account
hub / github.com/cloudwan/gohan / TestGetSchema

Function TestGetSchema

server/editor_test.go:27–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestGetSchema(t *testing.T) {
28 manager := schema.GetManager()
29 defer schema.ClearManager()
30
31 if err := manager.LoadSchemaFromFile("embed://etc/schema/gohan.json"); err != nil {
32 t.Error(err)
33 }
34 if err := manager.LoadSchemaFromFile("../tests/test_schema_member.yaml"); err != nil {
35 t.Error(err)
36 }
37
38 a := schema.NewAuthorization("member", "member", "member", []string{"Member"}, nil)
39 s, ok := manager.Schema("member_resource")
40 if !ok {
41 t.Error("Could not find schema")
42 }
43
44 r, err := GetSchema(s, a)
45 if err != nil {
46 t.Fatal("Unexpected error", err)
47 }
48
49 if !resourceMatches(r, "test-fixtures/editor_member.json") {
50 t.Fatal("Unexpected resource")
51 }
52}
53
54func resourceMatches(r *schema.Resource, path string) bool {
55 f, err := os.Open(path)

Callers

nothing calls this directly

Calls 6

GetSchemaFunction · 0.85
resourceMatchesFunction · 0.85
LoadSchemaFromFileMethod · 0.80
FatalMethod · 0.80
ErrorMethod · 0.65
SchemaMethod · 0.65

Tested by

no test coverage detected