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

Function TestCoderServicePrefix

tailnet/conn_test.go:508–520  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

506}
507
508func TestCoderServicePrefix(t *testing.T) {
509 t.Parallel()
510 a := tailnet.CoderServicePrefix.RandomAddr()
511 require.True(t, strings.HasPrefix(a.String(), "fd60:627a:a42b"))
512 p := tailnet.CoderServicePrefix.RandomPrefix()
513 require.True(t, strings.HasPrefix(p.String(), "fd60:627a:a42b"))
514 require.True(t, strings.HasSuffix(p.String(), "/128"))
515 u := uuid.MustParse("aaaaaaaa-aaaa-aaaa-aaaa-123456789abc")
516 a = tailnet.CoderServicePrefix.AddrFromUUID(u)
517 require.Equal(t, "fd60:627a:a42b:aaaa:aaaa:1234:5678:9abc", a.String())
518 p = tailnet.CoderServicePrefix.PrefixFromUUID(u)
519 require.Equal(t, "fd60:627a:a42b:aaaa:aaaa:1234:5678:9abc/128", p.String())
520}
521
522// TestSlogRemoteAddr tests that passing a nil net.Addr, as could be returned by conn.RemoteAddr(), does not cause a
523// problem when passed to slog.F

Callers

nothing calls this directly

Calls 6

RandomAddrMethod · 0.80
RandomPrefixMethod · 0.80
AddrFromUUIDMethod · 0.80
PrefixFromUUIDMethod · 0.80
StringMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected