43 lines
912 B
Go
43 lines
912 B
Go
package zjdg
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"github.com/stretchr/testify/suite"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"testing"
|
|
)
|
|
|
|
// api-单元测试
|
|
type apiClientSuite struct {
|
|
suite.Suite
|
|
api ZjdgApi
|
|
}
|
|
|
|
func TestApiClient(t *testing.T) {
|
|
suite.Run(t, new(apiClientSuite))
|
|
}
|
|
|
|
func (a *apiClientSuite) SetupSuite() {
|
|
log := logx.WithContext(context.Background())
|
|
apiClient := NewApiClient(log, AuthConfig{
|
|
UserId: "", //
|
|
})
|
|
a.api = apiClient
|
|
}
|
|
|
|
func (a *apiClientSuite) Test_ZoneAdd() {
|
|
req := ZoneAddRequest{}
|
|
result, err := a.api.ZoneAdd(context.Background(), req)
|
|
if !a.NoError(err) {
|
|
a.T().Errorf("========[Test_GenerateLink] response error:%s", err)
|
|
return
|
|
}
|
|
resultByte, err := json.Marshal(result)
|
|
if err != nil {
|
|
a.T().Errorf("========[Test_GenerateLink] json_marshal error:%s", err)
|
|
return
|
|
}
|
|
a.T().Logf("=====[Test_GenerateLink] result: %s", string(resultByte))
|
|
}
|