probo/models/group_test.go

29 строки
634 Б
Go

package models
import (
"github.com/remogatto/prettytest"
)
type groupTestSuite struct {
prettytest.Suite
}
func (t *groupTestSuite) TestMarshal() {
group := &Group{
Name: "Example group",
Participants: []*Participant{
{"123", "John", "Doe", 12345, map[string]string{"class": "1 D LIN", "age": "18"}},
{"456", "Jack", "Sparrow", 67890, map[string]string{"class": "1 D LIN", "age": "24"}},
},
}
expected := `id,firstname,lastname,token,attributes
123,John,Doe,12345,"age:18,class:1 D LIN"
456,Jack,Sparrow,67890,"age:24,class:1 D LIN"
`
csv, err := group.Marshal()
t.Nil(err)
t.Equal(expected, string(csv))
}