forked from eolinker/eosc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_test.go
53 lines (50 loc) · 1019 Bytes
/
file_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
package eosc
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func TestGzipFile_DecodeData(t *testing.T) {
type fields struct {
Name string
Type string
Size int
Data string
}
tests := []struct {
name string
fields fields
want []byte
wantErr assert.ErrorAssertionFunc
}{
{
name: "test",
fields: fields{
Name: "test.txt", Size: 4, Type: "text/plain", Data: "H4sIAAAAAAAAAytJLS4BAAx+f9gEAAAA",
},
want: []byte("test"),
wantErr: func(t assert.TestingT, err error, i ...interface{}) bool {
if err != nil {
t.Errorf("%s:%w", i[0], err)
return false
}
return true
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
f := &GzipFile{
Name: tt.fields.Name,
Type: tt.fields.Type,
Size: tt.fields.Size,
Data: tt.fields.Data,
}
got, err := f.DecodeData()
if !tt.wantErr(t, err, fmt.Sprintf("DecodeData()")) {
return
}
assert.Equalf(t, tt.want, got, "DecodeData()")
})
}
}