Adding initial code for the main.go as well as initial code for uploading members
This commit is contained in:
45
server/services/putmembers_test.go
Normal file
45
server/services/putmembers_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestParseMembersFromBytes(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
input string
|
||||
expected []Member
|
||||
}{
|
||||
{
|
||||
name: "Valid CSV with multiple members",
|
||||
input: `date,First,Last,Email
|
||||
2023-01-01,John,Doe,john.doe@example.com
|
||||
2023-01-02,Jane,Smith,jane.smith@example.com`,
|
||||
expected: []Member{
|
||||
{Name: "John Doe", Email: "john.doe@example.com"},
|
||||
{Name: "Jane Smith", Email: "jane.smith@example.com"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "CSV with missing fields",
|
||||
input: `date,First,Last
|
||||
2023-01-01,John,Doe`,
|
||||
expected: []Member{},
|
||||
},
|
||||
{
|
||||
name: "Empty CSV",
|
||||
input: ``,
|
||||
expected: []Member{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
members, err := ParseMembersFromBytes(2023, []byte(tc.input))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tc.expected, members)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user