Skip to content

Commit 21870ea

Browse files
author
ethanholen-hpe
committed
added tests for csm testing export
1 parent 725d6e7 commit 21870ea

File tree

3 files changed

+897
-0
lines changed

3 files changed

+897
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package export
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestSplitCSV(t *testing.T) {
8+
tests := []struct {
9+
name string
10+
input string
11+
expected []string
12+
}{
13+
{
14+
name: "passing test with comma-separated values",
15+
input: "name, type , status",
16+
expected: []string{"name", "type", "status"},
17+
},
18+
{
19+
name: "failing test with empty string returns empty slice",
20+
input: "",
21+
expected: []string{},
22+
},
23+
}
24+
25+
for _, tt := range tests {
26+
t.Run(tt.name, func(t *testing.T) {
27+
got := splitCSV(tt.input)
28+
29+
if len(got) != len(tt.expected) {
30+
t.Errorf("splitCSV() returned %d items, want %d", len(got), len(tt.expected))
31+
return
32+
}
33+
for i := range got {
34+
if got[i] != tt.expected[i] {
35+
t.Errorf("splitCSV()[%d] = %q, want %q", i, got[i], tt.expected[i])
36+
}
37+
}
38+
})
39+
}
40+
}

0 commit comments

Comments
 (0)