Skip to content

Commit 48c0c9c

Browse files
committed
fix(): fix unittest
1 parent 012b413 commit 48c0c9c

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module github.com/easyops-cn/giraffe-micro
22

3-
go 1.12
3+
go 1.13
44

55
require (
6-
github.com/easyops-cn/go-proto-giraffe v0.1.2
7-
github.com/go-test/deep v1.0.2
8-
github.com/gogo/protobuf v1.2.1
6+
github.com/easyops-cn/go-proto-giraffe v0.2.0
7+
github.com/go-test/deep v1.0.7
8+
github.com/gogo/protobuf v1.3.1
99
)

go.sum

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
github.com/easyops-cn/go-proto-giraffe v0.1.2 h1:yg1bMWix8Q7kGG4ttHR0CeyF8uzpaVU5+0to7goB+vM=
2-
github.com/easyops-cn/go-proto-giraffe v0.1.2/go.mod h1:T0Re9wVBu/7qUs/u0NEsmw1q7rTPzP7+bS1lVc+NwGA=
3-
github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw=
4-
github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
1+
github.com/easyops-cn/go-proto-giraffe v0.2.0 h1:vLw0ZRMOYi3l2MN8F+cZ4faxhzP511S2TY++zN83ux4=
2+
github.com/easyops-cn/go-proto-giraffe v0.2.0/go.mod h1:T0Re9wVBu/7qUs/u0NEsmw1q7rTPzP7+bS1lVc+NwGA=
3+
github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M=
4+
github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
55
github.com/gogo/protobuf v0.0.0-20190730201129-28a6bbf47e48/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
6-
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
7-
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
8-
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
6+
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
7+
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
98
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
109
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
11-
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
1210
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

plugins/restv2/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020

2121
type errNameService struct{}
2222

23-
func (e *errNameService) GetAddress(contract giraffe.Contract) (string, error) {
23+
func (e *errNameService) GetAddress(ctx context.Context, contract giraffe.Contract) (string, error) {
2424
return "", errors.New("always failed")
2525
}
2626

27-
func (e *errNameService) GetAllAddresses(contract giraffe.Contract) ([]string, error) {
27+
func (e *errNameService) GetAllAddresses(ctx context.Context, contract giraffe.Contract) ([]string, error) {
2828
return nil, errors.New("always failed")
2929
}
3030

plugins/restv2/staticaddr.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package restv2
22

3-
import "github.com/easyops-cn/giraffe-micro"
3+
import (
4+
"context"
5+
6+
"github.com/easyops-cn/giraffe-micro"
7+
)
48

59
type StaticAddress string
610

7-
func (s StaticAddress) GetAddress(contract giraffe.Contract) (string, error) {
11+
func (s StaticAddress) GetAddress(ctx context.Context, contract giraffe.Contract) (string, error) {
812
return string(s), nil
913
}
1014

11-
func (s StaticAddress) GetAllAddresses(contract giraffe.Contract) ([]string, error) {
15+
func (s StaticAddress) GetAllAddresses(ctx context.Context, contract giraffe.Contract) ([]string, error) {
1216
return []string{string(s)}, nil
1317
}

plugins/restv2/staticaddr_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package restv2
22

33
import (
4+
"context"
45
"reflect"
56
"testing"
67

@@ -28,7 +29,7 @@ func TestStaticAddress_GetAddress(t *testing.T) {
2829
}
2930
for _, tt := range tests {
3031
t.Run(tt.name, func(t *testing.T) {
31-
got, err := tt.s.GetAddress(tt.args.contract)
32+
got, err := tt.s.GetAddress(context.Background(), tt.args.contract)
3233
if (err != nil) != tt.wantErr {
3334
t.Errorf("GetAddress() error = %v, wantErr %v", err, tt.wantErr)
3435
return
@@ -61,7 +62,7 @@ func TestStaticAddress_GetAllAddresses(t *testing.T) {
6162
}
6263
for _, tt := range tests {
6364
t.Run(tt.name, func(t *testing.T) {
64-
got, err := tt.s.GetAllAddresses(tt.args.contract)
65+
got, err := tt.s.GetAllAddresses(context.Background(), tt.args.contract)
6566
if (err != nil) != tt.wantErr {
6667
t.Errorf("GetAllAddresses() error = %v, wantErr %v", err, tt.wantErr)
6768
return

0 commit comments

Comments
 (0)