forked from hungdv136/rio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stub_store_test.go
41 lines (32 loc) · 907 Bytes
/
stub_store_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
37
38
39
40
41
package rio
import (
"context"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
)
func TestStubMemory_CreateAndGetAll(t *testing.T) {
t.Parallel()
ctx := context.Background()
store := NewStubMemory()
stub := NewStub().For("GET", Contains("animal/create"))
require.NoError(t, store.Create(ctx, stub))
require.NotZero(t, stub.ID)
allItems, err := store.GetAll(ctx, "")
require.NoError(t, err)
require.Len(t, allItems, 1)
}
func TestStubMemory_CreateIncomingRequest(t *testing.T) {
t.Parallel()
ctx := context.Background()
store := NewStubMemory()
request := &IncomingRequest{
URL: uuid.NewString(),
Method: uuid.NewString(),
}
require.NoError(t, store.CreateIncomingRequest(ctx, request))
require.NotZero(t, request.ID)
requests, err := store.GetIncomingRequests(ctx, &IncomingQueryOption{})
require.NoError(t, err)
require.Len(t, requests, 1)
}