forked from go-openapi/spec
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcache_test.go
More file actions
34 lines (25 loc) · 791 Bytes
/
cache_test.go
File metadata and controls
34 lines (25 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers
// SPDX-License-Identifier: Apache-2.0
package spec
import (
"testing"
"github.com/go-openapi/testify/v2/assert"
)
func TestDefaultResolutionCache(t *testing.T) {
jsonSchema := MustLoadJSONSchemaDraft04()
swaggerSchema := MustLoadSwagger20Schema()
cache := defaultResolutionCache()
sch, ok := cache.Get("not there")
assert.False(t, ok)
assert.Nil(t, sch)
sch, ok = cache.Get("http://swagger.io/v2/schema.json")
assert.True(t, ok)
assert.Equal(t, swaggerSchema, sch)
sch, ok = cache.Get("http://json-schema.org/draft-04/schema")
assert.True(t, ok)
assert.Equal(t, jsonSchema, sch)
cache.Set("something", "here")
sch, ok = cache.Get("something")
assert.True(t, ok)
assert.Equal(t, "here", sch)
}