MCPcopy Index your code
hub / github.com/coder/coder / TestCompileHostnamePattern

Function TestCompileHostnamePattern

coderd/workspaceapps/appurl/appurl_test.go:296–530  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

294}
295
296func TestCompileHostnamePattern(t *testing.T) {
297 t.Parallel()
298
299 type matchCase struct {
300 input string
301 // empty string denotes no match
302 match string
303 }
304
305 type testCase struct {
306 name string
307 pattern string
308 errorContains string
309 // expectedRegex only needs to contain the inner part of the regex, not
310 // the prefix and suffix checks.
311 expectedRegex string
312 matchCases []matchCase
313 }
314
315 testCases := []testCase{
316 {
317 name: "Invalid_ContainsHTTP",
318 pattern: "http://*.hi.com",
319 errorContains: "must not contain a scheme",
320 },
321 {
322 name: "Invalid_ContainsHTTPS",
323 pattern: "https://*.hi.com",
324 errorContains: "must not contain a scheme",
325 },
326 {
327 name: "Invalid_StartPeriod",
328 pattern: ".hi.com",
329 errorContains: "must not start or end with a period",
330 },
331 {
332 name: "Invalid_EndPeriod",
333 pattern: "hi.com.",
334 errorContains: "must not start or end with a period",
335 },
336 {
337 name: "Invalid_Empty",
338 pattern: "",
339 errorContains: "must contain at least two labels",
340 },
341 {
342 name: "Invalid_SingleLabel",
343 pattern: "hi",
344 errorContains: "must contain at least two labels",
345 },
346 {
347 name: "Invalid_NoWildcard",
348 pattern: "hi.com",
349 errorContains: "must contain exactly one asterisk",
350 },
351 {
352 name: "Invalid_MultipleWildcards",
353 pattern: "**.hi.com",

Callers

nothing calls this directly

Calls 6

CompileHostnamePatternFunction · 0.92
ExecuteHostnamePatternFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected