123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package store
- import (
- "git.andreafazzi.eu/andrea/probo/pkg/models"
- "github.com/remogatto/prettytest"
- )
- type participantTestSuite struct {
- prettytest.Suite
- }
- func (t *participantTestSuite) TestCreate() {
- store := NewStore[*models.Participant]()
- p_1, err := store.Create(&models.Participant{
- Lastname: "Doe",
- Firstname: "John",
- })
- t.Nil(err)
- p_2, err := store.Create(&models.Participant{
- Lastname: "Doe",
- Firstname: "John",
- Attributes: map[string]string{"class": "1 D LIN"},
- })
- t.Nil(err)
- t.False(p_1.GetHash() == p_2.GetHash())
- }
- func (t *participantTestSuite) TestUpdate() {
- store := NewStore[*models.Participant]()
- p, err := store.Create(&models.Participant{
- Lastname: "Doe",
- Firstname: "John",
- })
- t.Nil(err)
- updatedP, err := store.Update(&models.Participant{
- Lastname: "Doe",
- Firstname: "John",
- Attributes: map[string]string{"class": "1 D LIN"},
- }, p.ID)
- t.Nil(err)
- t.False(p.GetHash() == updatedP.GetHash())
- }
- func (t *participantTestSuite) TestImportCSV() {
- store := NewParticipantStore()
- participants, err := store.ImportCSV("./testdata/participants.csv")
- t.Nil(err)
- t.Equal(3, len(participants))
- t.Equal("1 D LIN", participants[0].Attributes.Get("class"))
- t.Equal(6, len(participants[0].Token))
- }
|