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

Function TestValidatorForIdentifiers

pkg/unique/unique_test.go:131–248  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

129}
130
131func TestValidatorForIdentifiers(t *testing.T) {
132 a := assertions.New(t)
133 for _, run := range []struct {
134 Name string
135 ID func(string) ttnpb.IDStringer
136 Parser func(string) (ttnpb.IDStringer, error)
137 }{
138 {
139 "ApplicationID",
140 func(uid string) ttnpb.IDStringer { return &ttnpb.ApplicationIdentifiers{ApplicationId: uid} },
141 func(uid string) (ttnpb.IDStringer, error) { return ToApplicationID(uid) },
142 },
143 {
144 "ClientId",
145 func(uid string) ttnpb.IDStringer { return &ttnpb.ClientIdentifiers{ClientId: uid} },
146 func(uid string) (ttnpb.IDStringer, error) { return ToClientID(uid) },
147 },
148 {
149 "GatewayID",
150 func(uid string) ttnpb.IDStringer { return &ttnpb.GatewayIdentifiers{GatewayId: uid} },
151 func(uid string) (ttnpb.IDStringer, error) { return ToGatewayID(uid) },
152 },
153 {
154 "OrganizationID",
155 func(uid string) ttnpb.IDStringer { return &ttnpb.OrganizationIdentifiers{OrganizationId: uid} },
156 func(uid string) (ttnpb.IDStringer, error) { return ToOrganizationID(uid) },
157 },
158 {
159 "UserID",
160 func(uid string) ttnpb.IDStringer { return &ttnpb.UserIdentifiers{UserId: uid} },
161 func(uid string) (ttnpb.IDStringer, error) { return ToUserID(uid) },
162 },
163 } {
164 for _, tc := range []struct {
165 Name string
166 InputUID string
167 ExpectedError func(error) bool
168 }{
169 {
170 "ValidID",
171 "test",
172 nil,
173 },
174 {
175 "ValidMinLength",
176 "oza",
177 nil,
178 },
179 {
180 "ValidMaxLength",
181 "ozaj8qs0sait7oudxqbfyx6b14yuahcfrdlb",
182 nil,
183 },
184 {
185 "ValidNumerics",
186 "1id1",
187 nil,
188 },

Callers

nothing calls this directly

Calls 10

IsInvalidArgumentFunction · 0.92
ToApplicationIDFunction · 0.85
ToClientIDFunction · 0.85
ToGatewayIDFunction · 0.85
ToOrganizationIDFunction · 0.85
ToUserIDFunction · 0.85
NewMethod · 0.65
RunMethod · 0.65
FatalMethod · 0.65
IDMethod · 0.65

Tested by

no test coverage detected