File: pending.go

package info (click to toggle)
golang-gopkg-h2non-gock.v1 1.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 364 kB
  • sloc: makefile: 2
file content (27 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package main

import (
	"fmt"
	"gopkg.in/h2non/gock.v1"
	"net/http"
)

func main() {
	defer gock.Off()

	gock.New("http://httpbin.org").
		Get("/get").
		Reply(204).
		SetHeader("Server", "gock")

	fmt.Printf("Pending mocks before request: %d\n", len(gock.Pending()))
	fmt.Printf("Is pending before request: %#v\n", gock.IsPending())

	_, err := http.Get("http://httpbin.org/get")
	if err != nil {
		fmt.Errorf("Error: %s", err)
	}

	fmt.Printf("Pending mocks after request: %d\n", len(gock.Pending()))
	fmt.Printf("Is pending: %#v\n", gock.IsPending())
}