-
Notifications
You must be signed in to change notification settings - Fork 0
/
articles-grpc_test.go
45 lines (37 loc) · 1001 Bytes
/
articles-grpc_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
42
43
44
45
package goautowp
import (
"context"
"testing"
"github.com/autowp/goautowp/util"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
func TestGetArticles(t *testing.T) {
t.Parallel()
ctx := context.Background()
conn, err := grpc.NewClient(
"localhost",
grpc.WithContextDialer(bufDialer),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
require.NoError(t, err)
defer util.Close(conn)
client := NewArticlesClient(conn)
response1, err := client.GetList(
ctx,
&ArticlesRequest{},
)
require.NoError(t, err)
require.NotNil(t, response1)
require.Len(t, response1.GetItems(), 1)
require.Equal(t, int64(1), response1.GetItems()[0].GetId())
response2, err := client.GetItemByCatname(
ctx,
&ArticleByCatnameRequest{Catname: "test-article"},
)
require.NoError(t, err)
require.NotNil(t, response2)
require.Equal(t, int64(1), response2.GetId())
require.Equal(t, "Test html", response2.GetHtml())
}