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

Function Test_wrapTransportWithEntitlementsCheck

cli/root_internal_test.go:384–404  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

382}
383
384func Test_wrapTransportWithEntitlementsCheck(t *testing.T) {
385 t.Parallel()
386
387 lines := []string{"First Warning", "Second Warning"}
388 var buf bytes.Buffer
389 rt := wrapTransportWithEntitlementsCheck(roundTripper(func(req *http.Request) (*http.Response, error) {
390 return &http.Response{
391 StatusCode: http.StatusOK,
392 Header: http.Header{
393 codersdk.EntitlementsWarningHeader: lines,
394 },
395 Body: io.NopCloser(nil),
396 }, nil
397 }), &buf)
398 res, err := rt.RoundTrip(httptest.NewRequest(http.MethodGet, "http://example.com", nil))
399 require.NoError(t, err)
400 defer res.Body.Close()
401 expectedOutput := fmt.Sprintf("%s\n%s\n", pretty.Sprint(cliui.DefaultStyles.Warn, lines[0]),
402 pretty.Sprint(cliui.DefaultStyles.Warn, lines[1]))
403 require.Equal(t, expectedOutput, buf.String())
404}
405
406func Test_ensureTLSConfig(t *testing.T) {
407 t.Parallel()

Callers

nothing calls this directly

Calls 6

roundTripperFuncType · 0.70
CloseMethod · 0.65
RoundTripMethod · 0.45
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected