-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap-grpc_test.go
80 lines (62 loc) · 1.74 KB
/
map-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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package goautowp
import (
"context"
"fmt"
"math/rand"
"testing"
"time"
"github.com/autowp/goautowp/schema"
"github.com/doug-martin/goqu/v9"
"github.com/stretchr/testify/require"
)
func createItemWithPoint(ctx context.Context, t *testing.T) {
t.Helper()
random := rand.New(rand.NewSource(time.Now().UnixNano())) //nolint:gosec
goquDB, err := cnt.GoquDB()
require.NoError(t, err)
res, err := goquDB.Insert(schema.ItemTable).Rows(goqu.Record{
schema.ItemTableNameColName: fmt.Sprintf("vehicle-%d", random.Int()),
schema.ItemTableIsGroupColName: 0,
schema.ItemTableItemTypeIDColName: ItemType_ITEM_TYPE_VEHICLE,
schema.ItemTableCatnameColName: fmt.Sprintf("vehicle-%d", random.Int()),
schema.ItemTableBodyColName: "",
schema.ItemTableProducedExactlyColName: 0,
}).Executor().ExecContext(ctx)
require.NoError(t, err)
itemID, err := res.LastInsertId()
require.NoError(t, err)
_, err = goquDB.Insert(schema.ItemPointTable).Rows(goqu.Record{
schema.ItemPointTableItemIDColName: itemID,
schema.ItemPointTablePointColName: goqu.Func("point", 30, 30),
}).Executor().ExecContext(ctx)
require.NoError(t, err)
}
func TestGetPoints(t *testing.T) {
t.Parallel()
ctx := context.Background()
createItemWithPoint(ctx, t)
client := NewMapClient(conn)
_, err := client.GetPoints(
ctx,
&MapGetPointsRequest{
Bounds: "0,0,60,60",
Language: "en",
},
)
require.NoError(t, err)
}
func TestGetPointsOnly(t *testing.T) {
t.Parallel()
ctx := context.Background()
createItemWithPoint(ctx, t)
client := NewMapClient(conn)
_, err := client.GetPoints(
ctx,
&MapGetPointsRequest{
Bounds: "0,0,60,60",
Language: "en",
PointsOnly: true,
},
)
require.NoError(t, err)
}