-
Notifications
You must be signed in to change notification settings - Fork 2
/
location_test.go
41 lines (36 loc) · 928 Bytes
/
location_test.go
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
35
36
37
38
39
40
41
package openapi_test
import (
"testing"
"github.com/chanced/openapi"
"github.com/chanced/uri"
)
func TestLocationAppend(t *testing.T) {
u, _ := uri.Parse("https://example.org/schema/demo")
loc, err := openapi.NewLocation(*u)
if err != nil {
t.Fatal(err)
}
loc = loc.AppendLocation("foo")
expected := "https://example.org/schema/demo#/foo"
if loc.String() != expected {
t.Errorf("expected %q, got %s", expected, loc.String())
}
loc = loc.AppendLocation("bar")
expected = "https://example.org/schema/demo#/foo/bar"
if loc.String() != expected {
t.Errorf("expected %q, got %s", expected, loc.String())
}
u, err = uri.Parse("example.json")
if err != nil {
t.Fatal(err)
}
loc, err = openapi.NewLocation(*u)
if err != nil {
t.Fatal(err)
}
loc = loc.AppendLocation("foo")
expected = "example.json#/foo"
if loc.String() != expected {
t.Errorf("expected %q, got %s", expected, loc.String())
}
}