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

Function TestIsReplicaRelayRequest

cli/server_internal_test.go:318–340  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

316}
317
318func TestIsReplicaRelayRequest(t *testing.T) {
319 t.Parallel()
320
321 t.Run("WithHeader", func(t *testing.T) {
322 t.Parallel()
323 r, _ := http.NewRequestWithContext(context.Background(), "GET", "/api/experimental/chats/abc/stream", nil)
324 r.Header.Set("X-Coder-Relay-Source-Replica", "some-uuid")
325 require.True(t, isReplicaRelayRequest(r))
326 })
327
328 t.Run("WithoutHeader", func(t *testing.T) {
329 t.Parallel()
330 r, _ := http.NewRequestWithContext(context.Background(), "GET", "/api/experimental/chats/abc/stream", nil)
331 require.False(t, isReplicaRelayRequest(r))
332 })
333
334 t.Run("EmptyHeader", func(t *testing.T) {
335 t.Parallel()
336 r, _ := http.NewRequestWithContext(context.Background(), "GET", "/api/experimental/chats/abc/stream", nil)
337 r.Header.Set("X-Coder-Relay-Source-Replica", "")
338 require.False(t, isReplicaRelayRequest(r))
339 })
340}
341
342func TestEscapePostgresURLUserInfo(t *testing.T) {
343 t.Parallel()

Callers

nothing calls this directly

Calls 3

isReplicaRelayRequestFunction · 0.85
RunMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected