probo/store/file/participant_test.go
2023-11-20 14:14:09 +01:00

42 lines
916 B
Go

package file
import (
"os"
"git.andreafazzi.eu/andrea/probo/models"
"git.andreafazzi.eu/andrea/probo/store"
"github.com/remogatto/prettytest"
)
type participantTestSuite struct {
prettytest.Suite
}
func (t *participantTestSuite) TestCreate() {
filePathConfig := FilePathConfig{"testdata/participants", "participant", ".json"}
pStore, err := NewParticipantFileStore(
&FileStoreConfig[*models.Participant, *store.ParticipantStore]{
FilePathConfig: filePathConfig,
IndexDirFunc: DefaultIndexDirFunc[*models.Participant, *store.ParticipantStore],
})
t.Nil(err)
if !t.Failed() {
p, err := pStore.Create(&models.Participant{
Lastname: "Doe",
Firstname: "John",
Attributes: map[string]string{"class": "1 D LIN"},
})
t.Nil(err)
defer os.Remove(pStore.GetPath(p))
if !t.Failed() {
exists, err := os.Stat(pStore.GetPath(p))
t.Nil(err)
t.Not(t.Nil(exists))
}
}
}