2021-09-23 23:01:18 +00:00
|
|
|
package memory_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-10-05 06:54:36 +00:00
|
|
|
"path"
|
2021-09-23 23:01:18 +00:00
|
|
|
"sync"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
2021-09-29 20:35:39 +00:00
|
|
|
|
2021-10-05 06:54:36 +00:00
|
|
|
repository "source.toby3d.me/website/oauth/internal/client/repository/memory"
|
2021-09-29 20:35:39 +00:00
|
|
|
"source.toby3d.me/website/oauth/internal/domain"
|
2021-09-23 23:01:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGet(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2021-09-29 20:35:39 +00:00
|
|
|
client := domain.TestClient(t)
|
2021-09-23 23:01:18 +00:00
|
|
|
|
2021-12-29 20:53:31 +00:00
|
|
|
store := new(sync.Map)
|
|
|
|
store.Store(path.Join(repository.DefaultPathPrefix, client.ID.String()), client)
|
2021-09-23 23:01:18 +00:00
|
|
|
|
2021-10-05 06:54:36 +00:00
|
|
|
result, err := repository.NewMemoryClientRepository(store).Get(context.TODO(), client.ID)
|
2021-09-23 23:01:18 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, client, result)
|
|
|
|
}
|