package themis import ( "context" "fmt" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestAddAbsence(t *testing.T) { store, err := NewStore(fmt.Sprintf(TEST_CONN_STRING_PATTERN, "TestAddAbsence")) require.NoError(t, err) now := NextMonday() assert.NoError(t, store.AddAbsence(context.TODO(), now, "foobarbaz")) absentees, err := store.GetAbsentees(context.TODO(), now) assert.NoError(t, err) assert.Equal(t, 1, len(absentees)) assert.Equal(t, "foobarbaz", absentees[0]) assert.NoError(t, store.AddAbsence(context.TODO(), now, "foobarbaz")) absentees, err = store.GetAbsentees(context.TODO(), now) assert.NoError(t, err) assert.Equal(t, 1, len(absentees)) } func TestGetSchedule(t *testing.T) { store, err := NewStore(fmt.Sprintf(TEST_CONN_STRING_PATTERN, "TestGetSchedule")) require.NoError(t, err) now := NextMonday() _ = store.AddAbsence(context.TODO(), now.Add(7*24*time.Hour), "foobar") schedule, err := store.GetSchedule(context.TODO(), now, now.Add(2*7*24*time.Hour)) assert.NoError(t, err) assert.Equal(t, 1, len(schedule)) }