-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio_test.go
99 lines (95 loc) · 2.12 KB
/
io_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
88
89
90
91
92
93
94
95
96
97
98
99
package simplecsv
import (
"reflect"
"testing"
)
func TestCreateEmpyCsv(t *testing.T) {
type args struct {
columnNames []string
}
tests := []struct {
name string
args args
want SimpleCsv
}{
{name: "CreateEmpyCsv",
want: SimpleCsv{{"Ann", "Ban", "Cann"}},
args: args{columnNames: []string{"Ann", "Ban", "Cann"}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := CreateEmpyCsv(tt.args.columnNames); !reflect.DeepEqual(got, tt.want) {
t.Errorf("CreateEmpyCsv() = %v, want %v", got, tt.want)
}
})
}
}
func TestReadCsvFile(t *testing.T) {
type args struct {
filename string
}
tests := []struct {
name string
args args
want SimpleCsv
want1 bool
}{
{name: "ReadCsvFile1", args: args{filename: "testdata/small.csv"},
want: SimpleCsv{
{"Nome", "Email", "Telefono"},
{"Osvaldo", "[email protected]", "111"},
{"Isabel", "[email protected]", "222"},
{"Carlos", "[email protected]", "333"},
{"Marisa", "[email protected]", "444"},
},
want1: true,
},
{name: "ReadCsvFile2", args: args{filename: "doesntexist.csv"},
want1: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, got1 := ReadCsvFile(tt.args.filename)
if got1 != tt.want1 {
t.Errorf("ReadCsvFile() got1 = %v, want %v", got1, tt.want1)
}
})
}
}
func TestSimpleCsv_WriteCsvFile(t *testing.T) {
type args struct {
filename string
}
tests := []struct {
name string
s SimpleCsv
args args
want bool
}{
{name: "WriteCsvFile1",
args: args{filename: "testdata/small.csv"},
want: true,
s: SimpleCsv{
{"Nome", "Email", "Telefono"},
{"Osvaldo", "[email protected]", "111"},
{"Isabel", "[email protected]", "222"},
{"Carlos", "[email protected]", "333"},
{"Marisa", "[email protected]", "444"},
},
},
{name: "WriteCsvFile2",
args: args{filename: ""},
want: false,
s: SimpleCsv{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.s.WriteCsvFile(tt.args.filename); got != tt.want {
t.Errorf("SimpleCsv.WriteCsvFile() = %v, want %v", got, tt.want)
}
})
}
}