File: fake_poster_test.go

package info (click to toggle)
golang-ginkgo 1.2.0+git20161006.acfa16a-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,324 kB
  • ctags: 1,210
  • sloc: makefile: 12
file content (33 lines) | stat: -rw-r--r-- 566 bytes parent folder | download | duplicates (3)
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
28
29
30
31
32
33
package remote_test

import (
	"io"
	"io/ioutil"
	"net/http"
)

type post struct {
	url         string
	bodyType    string
	bodyContent []byte
}

type fakePoster struct {
	posts []post
}

func newFakePoster() *fakePoster {
	return &fakePoster{
		posts: make([]post, 0),
	}
}

func (poster *fakePoster) Post(url string, bodyType string, body io.Reader) (resp *http.Response, err error) {
	bodyContent, _ := ioutil.ReadAll(body)
	poster.posts = append(poster.posts, post{
		url:         url,
		bodyType:    bodyType,
		bodyContent: bodyContent,
	})
	return nil, nil
}