MCPcopy Create free account
hub / github.com/pace/bricks / TestIntegrationExample

Function TestIntegrationExample

test/livetest/livetest_test.go:15–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestIntegrationExample(t *testing.T) {
16 if testing.Short() {
17 t.Skip()
18 return
19 }
20
21 ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*100)
22 defer cancel()
23
24 err := Test(ctx, []TestFunc{
25 func(t *T) {
26 t.Logf("Executed test no %d", 1)
27 },
28 func(t *T) {
29 t.Log("Executed test no 2")
30 },
31 func(t *T) {
32 t.Fatal("Fail test no 3")
33 },
34 func(t *T) {
35 t.Fatalf("Fail test no %d", 4)
36 },
37 func(t *T) {
38 t.Skip("Skipping test no 5")
39 },
40 func(t *T) {
41 t.Skipf("Skipping test no %d", 5)
42 },
43 func(t *T) {
44 t.SkipNow()
45 },
46 func(t *T) {
47 t.Fail()
48 },
49 func(t *T) {
50 t.FailNow()
51 },
52 func(t *T) {
53 t.Error("Some")
54 },
55 func(t *T) {
56 t.Errorf("formatted")
57 },
58 })
59 if err != context.DeadlineExceeded {
60 t.Error(err)
61 return
62 }
63
64 req := httptest.NewRequest("GET", "/metrics", nil)
65 resp := httptest.NewRecorder()
66 metric.Handler().ServeHTTP(resp, req)
67 body := resp.Body.String()
68
69 sn := cfg.ServiceName
70 if !strings.Contains(body, `pace_livetest_total{result="failed",service="`+sn+`"} 6`) ||
71 !strings.Contains(body, `pace_livetest_total{result="skipped",service="`+sn+`"} 3`) ||
72 !strings.Contains(body, `pace_livetest_total{result="succeeded",service="`+sn+`"} 2`) {

Callers

nothing calls this directly

Calls 15

HandlerFunction · 0.92
SkipMethod · 0.80
LogfMethod · 0.80
LogMethod · 0.80
FatalMethod · 0.80
FatalfMethod · 0.80
SkipfMethod · 0.80
SkipNowMethod · 0.80
FailMethod · 0.80
FailNowMethod · 0.80
ErrorfMethod · 0.80
TestFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…