File: tracehelper_test.go

package info (click to toggle)
golang-github-mwitkow-go-conntrack 0.0~git20190716.2f06839-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 180 kB
  • sloc: makefile: 3; sh: 1
file content (23 lines) | stat: -rw-r--r-- 605 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package conntrack_test

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"net/http/httptest"
	"testing"

	"github.com/stretchr/testify/require"
	"golang.org/x/net/trace"
)

func fetchTraceEvents(t *testing.T, familyName string) string {
	resp := httptest.NewRecorder()
	url := fmt.Sprintf("/debug/events?fam=%s&b=0&exp=1", familyName)
	req, err := http.NewRequest("GET", url, nil)
	require.NoError(t, err, "failed creating request for Prometheus handler")
	trace.RenderEvents(resp, req, true)
	out, err := ioutil.ReadAll(resp.Body)
	require.NoError(t, err, "failed reading the trace page")
	return string(out)
}