53 lines
971 B
Go
53 lines
971 B
Go
|
package store
|
||
|
|
||
|
import (
|
||
|
"git.andreafazzi.eu/andrea/probo/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())
|
||
|
}
|