Skip to content

Commit df84c13

Browse files
committed
Some dummy client store tests
1 parent d7c3316 commit df84c13

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

client_store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package pg
22

33
import (
44
"fmt"
5-
"github.com/json-iterator/go"
6-
"gopkg.in/oauth2.v3/models"
75
"log"
86
"os"
97

8+
"github.com/json-iterator/go"
109
"gopkg.in/oauth2.v3"
10+
"gopkg.in/oauth2.v3/models"
1111
)
1212

1313
// ClientStore PostgreSQL client store

client_store_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package pg
2+
3+
import (
4+
"strings"
5+
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestClientStore_initTable(t *testing.T) {
12+
adapter := new(mockAdapter)
13+
14+
_, err := NewClientStore(adapter)
15+
require.NoError(t, err)
16+
17+
assert.Equal(t, 1, len(adapter.execCalls))
18+
assert.Equal(t, 0, len(adapter.selectOneCalls))
19+
20+
// new line character is the character at position 0
21+
assert.Equal(t, 1, strings.Index(adapter.execCalls[0].query, "CREATE TABLE IF NOT EXISTS"))
22+
}

token_store_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (a *mockAdapter) SelectOne(dst interface{}, query string, args ...interface
4242
return nil
4343
}
4444

45-
func Test_initTable(t *testing.T) {
45+
func TestTokenStore_initTable(t *testing.T) {
4646
adapter := new(mockAdapter)
4747

4848
store, err := NewTokenStore(adapter, WithTokenStoreGCDisabled())
@@ -59,7 +59,7 @@ func Test_initTable(t *testing.T) {
5959
assert.Equal(t, 1, strings.Index(adapter.execCalls[0].query, "CREATE TABLE IF NOT EXISTS"))
6060
}
6161

62-
func Test_gc(t *testing.T) {
62+
func TestTokenStore_gc(t *testing.T) {
6363
adapter := new(mockAdapter)
6464

6565
store, err := NewTokenStore(adapter, WithTokenStoreInitTableDisabled(), WithTokenStoreGCInterval(time.Second))

0 commit comments

Comments
 (0)