You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
1 year ago
|
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))
|
||
|
}
|