group_test.go 634 B

1234567891011121314151617181920212223242526272829
  1. package models
  2. import (
  3. "github.com/remogatto/prettytest"
  4. )
  5. type groupTestSuite struct {
  6. prettytest.Suite
  7. }
  8. func (t *groupTestSuite) TestMarshal() {
  9. group := &Group{
  10. Name: "Example group",
  11. Participants: []*Participant{
  12. {"123", "John", "Doe", 12345, map[string]string{"class": "1 D LIN", "age": "18"}},
  13. {"456", "Jack", "Sparrow", 67890, map[string]string{"class": "1 D LIN", "age": "24"}},
  14. },
  15. }
  16. expected := `id,firstname,lastname,token,attributes
  17. 123,John,Doe,12345,"age:18,class:1 D LIN"
  18. 456,Jack,Sparrow,67890,"age:24,class:1 D LIN"
  19. `
  20. csv, err := group.Marshal()
  21. t.Nil(err)
  22. t.Equal(expected, string(csv))
  23. }