-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
36 lines (30 loc) · 920 Bytes
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package gooauth2gorm_test
import (
"context"
"testing"
"github.com/go-oauth2/oauth2/v4/models"
gooauth2gorm "github.com/nouhoum/go-oauth2-gorm"
"github.com/stretchr/testify/assert"
)
func TestClientStore(t *testing.T) {
store := gooauth2gorm.NewClientStoreWithDB(&gooauth2gorm.Config{DBType: gooauth2gorm.PostgresSQL}, db, "")
ctx := context.Background()
info := &models.Client{
ID: "client1",
Secret: "secret",
UserID: "user1",
Domain: "http://localhost",
}
err := store.Create(ctx, info)
assert.Nil(t, err, "store.Create")
client, err := store.GetByID(ctx, info.ID)
assert.Nil(t, err, "store.GetByID")
assert.Equal(t, info.ID, client.GetID())
//Remove by code
clientID := client.GetID()
err = store.RemoveByID(ctx, clientID)
assert.Nil(t, err)
unknownClient, err := store.GetByID(ctx, clientID)
assert.Nil(t, err, "store.GetByID")
assert.Nil(t, unknownClient, "store.GetByID")
}