forked from ricallinson/forgery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocks_test.go
47 lines (37 loc) · 789 Bytes
/
mocks_test.go
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package f
import (
"errors"
"net/http"
)
/*
Create a Mock http.ResponseWriter for testing.
*/
type MockResponseWriter struct {
error bool
headers http.Header
Written []byte
}
func (this *MockResponseWriter) Header() http.Header {
return this.headers
}
func (this *MockResponseWriter) Write(data []byte) (int, error) {
if this.error {
return 0, errors.New("")
}
this.Written = data
return len(data), nil
}
func (this *MockResponseWriter) WriteHeader(code int) {
return
}
func NewMockResponseWriter(error bool) *MockResponseWriter {
return &MockResponseWriter{error: error, headers: make(http.Header)}
}
/*
Create a Mock Renderer.
*/
type MockRenderer struct {
}
func (this *MockRenderer) Render(v string, i ...interface{}) (string, error) {
return v, nil
}