-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes_test.go
87 lines (70 loc) · 1.57 KB
/
types_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package request_test
import (
"encoding/base64"
"fmt"
"testing"
"github.com/gildas/go-errors"
"github.com/stretchr/testify/assert"
)
type failingReader int
func (r failingReader) Read(data []byte) (int, error) {
return 0, errors.NotImplemented.WithStack()
}
func (r failingReader) Close() error {
return nil
}
type stuff struct {
ID string
}
func (s stuff) String() string {
return s.ID
}
type progressWriter struct {
Total int64
Max int64
}
func (w *progressWriter) Write(p []byte) (n int, err error) {
w.Total += int64(len(p))
return len(p), nil
}
func (w *progressWriter) Close() error {
return nil
}
type progressWriter2 struct {
Total int64
Max int64
}
func (w *progressWriter2) SetMax64(max int64) {
w.Max = max
}
func (w *progressWriter2) Write(p []byte) (n int, err error) {
w.Total += int64(len(p))
return len(p), nil
}
type progressWriter3 struct {
Total int64
Max int64
}
func (w *progressWriter3) ChangeMax64(max int64) {
w.Max = max
}
func (w *progressWriter3) Write(p []byte) (n int, err error) {
w.Total += int64(len(p))
return len(p), nil
}
func TestStuffShouldBeStringer(t *testing.T) {
s := stuff{"1234"}
var z interface{} = s
assert.NotNil(t, z.(fmt.Stringer), "Integer type is not a Stringer")
}
// smallPNG returns a small PNG image as a byte array
//
// This is a 1x1 pixel PNG image and is 408 bytes in size
func smallPNG() []byte {
image := "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="
data, err := base64.StdEncoding.DecodeString(image)
if err != nil {
panic(err)
}
return data
}