Home / Function/ testRequest() — gin Function Reference

testRequest() — gin Function Reference

Architecture documentation for the testRequest() function in gin_integration_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  0cb54875_e9be_d799_8e29_6666cf3d9cd7["testRequest()"]
  fb10915c_585d_4daa_20dd_2fbe3863b19e["TestRunEmpty()"]
  fb10915c_585d_4daa_20dd_2fbe3863b19e -->|calls| 0cb54875_e9be_d799_8e29_6666cf3d9cd7
  807dbf1a_5da2_d76d_edab_06d7b1a182a8["TestRunTLS()"]
  807dbf1a_5da2_d76d_edab_06d7b1a182a8 -->|calls| 0cb54875_e9be_d799_8e29_6666cf3d9cd7
  db8f3798_e838_6bbb_bc3c_deafa505c362["TestPusher()"]
  db8f3798_e838_6bbb_bc3c_deafa505c362 -->|calls| 0cb54875_e9be_d799_8e29_6666cf3d9cd7
  0c01fdcd_a60c_e9cb_8f4b_aeeb2724022c["TestRunEmptyWithEnv()"]
  0c01fdcd_a60c_e9cb_8f4b_aeeb2724022c -->|calls| 0cb54875_e9be_d799_8e29_6666cf3d9cd7
  85d05d41_699f_c2fc_da73_6d7af7ead393["TestRunWithPort()"]
  85d05d41_699f_c2fc_da73_6d7af7ead393 -->|calls| 0cb54875_e9be_d799_8e29_6666cf3d9cd7
  1f27be73_41c0_0b4e_6320_b39b954f487d["TestRunQUIC()"]
  1f27be73_41c0_0b4e_6320_b39b954f487d -->|calls| 0cb54875_e9be_d799_8e29_6666cf3d9cd7
  8233929f_e678_5553_fdf5_79edefff31a7["TestWithHttptestWithAutoSelectedPort()"]
  8233929f_e678_5553_fdf5_79edefff31a7 -->|calls| 0cb54875_e9be_d799_8e29_6666cf3d9cd7
  06b302d0_95f7_cc08_4b90_e28564372ac1["TestTreeRunDynamicRouting()"]
  06b302d0_95f7_cc08_4b90_e28564372ac1 -->|calls| 0cb54875_e9be_d799_8e29_6666cf3d9cd7
  2a522dce_0f60_1760_7648_6dc5679436c7["TestEscapedColon()"]
  2a522dce_0f60_1760_7648_6dc5679436c7 -->|calls| 0cb54875_e9be_d799_8e29_6666cf3d9cd7
  style 0cb54875_e9be_d799_8e29_6666cf3d9cd7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

gin_integration_test.go lines 31–64

func testRequest(t *testing.T, params ...string) {
	if len(params) == 0 {
		t.Fatal("url cannot be empty")
	}

	tr := &http.Transport{
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: true,
		},
	}
	client := &http.Client{Transport: tr}

	resp, err := client.Get(params[0])
	require.NoError(t, err)
	defer resp.Body.Close()

	body, ioerr := io.ReadAll(resp.Body)
	require.NoError(t, ioerr)

	responseStatus := "200 OK"
	if len(params) > 1 && params[1] != "" {
		responseStatus = params[1]
	}

	responseBody := "it worked"
	if len(params) > 2 && params[2] != "" {
		responseBody = params[2]
	}

	assert.Equal(t, responseStatus, resp.Status, "should get a "+responseStatus)
	if responseStatus == "200 OK" {
		assert.Equal(t, responseBody, string(body), "resp body should match")
	}
}

Domain

Subdomains

Frequently Asked Questions

What does testRequest() do?
testRequest() is a function in the gin codebase.
What calls testRequest()?
testRequest() is called by 9 function(s): TestEscapedColon, TestPusher, TestRunEmpty, TestRunEmptyWithEnv, TestRunQUIC, TestRunTLS, TestRunWithPort, TestTreeRunDynamicRouting, and 1 more.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free