MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestWithBasePath

Function TestWithBasePath

pkg/fetch/basepath_test.go:37–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestWithBasePath(t *testing.T) {
38 for _, tc := range []struct {
39 Name string
40 BasePath, Path []string
41 Error error
42 Bytes []byte
43 AssertPath func(*testing.T, ...string) bool
44 AssertError func(*testing.T, error) bool
45 AssertBytes func(*testing.T, []byte) bool
46 }{
47 {
48 Name: "empty base path/empty path",
49 AssertPath: func(t *testing.T, pathElements ...string) bool {
50 return assertions.New(t).So(pathElements, should.BeEmpty)
51 },
52 AssertError: func(t *testing.T, err error) bool {
53 return assertions.New(t).So(err, should.BeError)
54 },
55 AssertBytes: func(t *testing.T, b []byte) bool {
56 return assertions.New(t).So(b, should.BeNil)
57 },
58 },
59 {
60 Name: "empty base path/path [foo bar baz]",
61 Path: []string{"foo", "bar", "baz"},
62 Bytes: []byte{0x42, 0x41},
63 AssertPath: func(t *testing.T, pathElements ...string) bool {
64 return assertions.New(t).So(pathElements, should.Resemble, []string{"foo", "bar", "baz"})
65 },
66 AssertError: func(t *testing.T, err error) bool {
67 return assertions.New(t).So(err, should.BeNil)
68 },
69 AssertBytes: func(t *testing.T, b []byte) bool {
70 return assertions.New(t).So(b, should.Resemble, []byte{0x42, 0x41})
71 },
72 },
73 {
74 Name: "empty base path/path [/foo bar baz]",
75 Path: []string{"/foo", "bar", "baz"},
76 Bytes: []byte{0x42, 0x41},
77 AssertPath: func(t *testing.T, pathElements ...string) bool {
78 return assertions.New(t).So(pathElements, should.Resemble, []string{"/foo", "bar", "baz"})
79 },
80 AssertError: func(t *testing.T, err error) bool {
81 return assertions.New(t).So(err, should.BeNil)
82 },
83 AssertBytes: func(t *testing.T, b []byte) bool {
84 return assertions.New(t).So(b, should.Resemble, []byte{0x42, 0x41})
85 },
86 },
87 {
88 Name: "base [foo bar baz]/empty path",
89 BasePath: []string{"foo", "bar", "baz"},
90 AssertPath: func(t *testing.T, pathElements ...string) bool {
91 return assertions.New(t).So(pathElements, should.Resemble, []string{"foo", "bar", "baz"})
92 },
93 AssertError: func(t *testing.T, err error) bool {
94 return assertions.New(t).So(err, should.BeError)

Callers

nothing calls this directly

Calls 5

WithBasePathFunction · 0.92
NewMethod · 0.65
RunMethod · 0.65
FileMethod · 0.65
CloneMethod · 0.45

Tested by

no test coverage detected