MCPcopy Create free account
hub / github.com/go-openapi/spec / TestDefaultResolutionCache

Function TestDefaultResolutionCache

cache_test.go:12–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestDefaultResolutionCache(t *testing.T) {
13 jsonSchema := MustLoadJSONSchemaDraft04()
14 swaggerSchema := MustLoadSwagger20Schema()
15
16 cache := defaultResolutionCache()
17
18 sch, ok := cache.Get("not there")
19 assert.FalseT(t, ok)
20 assert.Nil(t, sch)
21
22 sch, ok = cache.Get("http://swagger.io/v2/schema.json")
23 assert.TrueT(t, ok)
24 assert.Equal(t, swaggerSchema, sch)
25
26 sch, ok = cache.Get("http://json-schema.org/draft-04/schema")
27 assert.TrueT(t, ok)
28 assert.Equal(t, jsonSchema, sch)
29
30 cache.Set("something", "here")
31 sch, ok = cache.Get("something")
32 assert.TrueT(t, ok)
33 assert.Equal(t, "here", sch)
34}

Callers

nothing calls this directly

Calls 5

MustLoadSwagger20SchemaFunction · 0.85
defaultResolutionCacheFunction · 0.85
GetMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…