34 lines
773 B
Go
34 lines
773 B
Go
|
package bundb_test
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"gitea.dwysokinski.me/twhelp/dcbot/internal/bundb"
|
||
|
"gitea.dwysokinski.me/twhelp/dcbot/internal/domain"
|
||
|
"github.com/google/uuid"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"github.com/stretchr/testify/require"
|
||
|
)
|
||
|
|
||
|
func TestGroup_Create(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
|
||
|
repo := bundb.NewGroup(newDB(t))
|
||
|
|
||
|
t.Run("OK", func(t *testing.T) {
|
||
|
t.Parallel()
|
||
|
|
||
|
params, err := domain.NewCreateGroupParams("592292203234328587")
|
||
|
require.NoError(t, err)
|
||
|
|
||
|
group, err := repo.Create(context.Background(), params)
|
||
|
assert.NoError(t, err)
|
||
|
_, err = uuid.Parse(group.ID)
|
||
|
assert.NoError(t, err)
|
||
|
assert.Equal(t, params.ServerID(), group.ServerID)
|
||
|
assert.WithinDuration(t, time.Now(), group.CreatedAt, 1*time.Second)
|
||
|
})
|
||
|
}
|