-
Notifications
You must be signed in to change notification settings - Fork 3
/
client_test.go
46 lines (41 loc) · 969 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
37
38
39
40
41
42
43
44
45
46
package temu
import (
"context"
"fmt"
"github.com/goccy/go-json"
"github.com/hiscaler/temu-go/config"
"github.com/hiscaler/temu-go/entity"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
var temuClient *Client
var ctx context.Context
func TestMain(m *testing.M) {
b, err := os.ReadFile("./config/config.json")
if err != nil {
panic(fmt.Sprintf("Read config error: %s", err.Error()))
}
var cfg config.Config
err = json.Unmarshal(b, &cfg)
if err != nil {
panic(fmt.Sprintf("Parse config file error: %s", err.Error()))
}
temuClient = NewClient(cfg)
ctx = context.Background()
m.Run()
}
func TestClient_SetRegionId(t *testing.T) {
tests := []struct {
name string
regionId int
expectRegionId int
}{
{"t1", 1, 0},
{"t2", entity.AmericanRegionId, entity.AmericanRegionId},
}
for _, tt := range tests {
temuClient.SetRegionId(tt.regionId)
assert.Equalf(t, tt.expectRegionId, temuClient.RegionId, tt.name)
}
}