MCPcopy
hub / github.com/gin-gonic/gin / TestLoadHTMLFilesUsingTLS

Function TestLoadHTMLFilesUsingTLS

gin_test.go:281–306  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

279}
280
281func TestLoadHTMLFilesUsingTLS(t *testing.T) {
282 ts := setupHTMLFiles(
283 t,
284 TestMode,
285 true,
286 func(router *Engine) {
287 router.LoadHTMLFiles("./testdata/template/hello.tmpl", "./testdata/template/raw.tmpl")
288 },
289 )
290 defer ts.Close()
291
292 // Use InsecureSkipVerify for avoiding `x509: certificate signed by unknown authority` error
293 tr := &http.Transport{
294 TLSClientConfig: &tls.Config{
295 InsecureSkipVerify: true,
296 },
297 }
298 client := &http.Client{Transport: tr}
299 res, err := client.Get(ts.URL + "/test")
300 if err != nil {
301 t.Error(err)
302 }
303
304 resp, _ := io.ReadAll(res.Body)
305 assert.Equal(t, "<h1>Hello world</h1>", string(resp))
306}
307
308func TestLoadHTMLFilesFuncMap(t *testing.T) {
309 ts := setupHTMLFiles(

Callers

nothing calls this directly

Calls 5

setupHTMLFilesFunction · 0.85
LoadHTMLFilesMethod · 0.80
CloseMethod · 0.80
GetMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected