47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
|
package back_test
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"github.com/matryer/is"
|
||
|
"gitlab.codemonkeysoftware.net/b/henwen/back"
|
||
|
)
|
||
|
|
||
|
func TestNewMemoryStore(t *testing.T) {
|
||
|
is := is.New(t)
|
||
|
store, err := back.NewMemoryStore(back.SecureGenString)
|
||
|
is.NoErr(err)
|
||
|
is.True(store != nil)
|
||
|
store.Close()
|
||
|
}
|
||
|
|
||
|
func TestCreateEvent(t *testing.T) {
|
||
|
is := is.New(t)
|
||
|
store, err := back.NewMemoryStore(back.SecureGenString)
|
||
|
is.NoErr(err)
|
||
|
defer store.Close()
|
||
|
|
||
|
earliest := time.Date(2020, 04, 05, 0, 0, 0, 0, time.UTC)
|
||
|
latest := time.Date(2020, 04, 05, 0, 0, 0, 0, time.UTC)
|
||
|
const name = "abc"
|
||
|
const description = "def"
|
||
|
createResult, err := store.CreateEvent(context.Background(), back.CreateEventCommand{
|
||
|
Name: name,
|
||
|
Description: description,
|
||
|
EarliestDate: earliest,
|
||
|
LatestDate: latest,
|
||
|
})
|
||
|
is.NoErr(err)
|
||
|
|
||
|
metadataResult, err := store.GetEventMetadata(context.Background(), back.GetEventMetadataQuery{
|
||
|
AlphaID: createResult.AlphaID,
|
||
|
})
|
||
|
is.NoErr(err)
|
||
|
is.Equal(metadataResult.Name, name)
|
||
|
is.Equal(metadataResult.Description, description)
|
||
|
is.True(metadataResult.EarliestDate.Equal(earliest))
|
||
|
is.True(metadataResult.LatestDate.Equal(latest))
|
||
|
}
|