Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 69 additions & 56 deletions api_performance_review_data_get.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions impl_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ type RawRequestReq struct {

// 把可读的 RawRequestReq ,解析为 http 请求的参数 rawHttpRequestParam
func (r *Lark) parseRawHttpRequest(ctx context.Context, req *RawRequestReq) (*rawHttpRequest, error) {
if req.MethodOption == nil {
req.MethodOption = new(MethodOption)
}

// 0 init
rawHttpReq := &rawHttpRequest{
Scope: req.Scope,
Expand Down
50 changes: 44 additions & 6 deletions test/ai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ import (
"github.com/chyroc/lark"
)

const aiAPIFrequencyLimitErrCode int64 = 99991400

func skipIfAIFrequencyLimited(t *testing.T, err error) bool {
if err == nil {
return false
}
code := lark.GetErrorCode(err)
if code == aiAPIFrequencyLimitErrCode || strings.Contains(strings.ToLower(err.Error()), "frequency limit") {
t.Skipf("skip flaky ai api check due to frequency limit: %v", err)
return true
}
return false
}

func Test_AI(t *testing.T) {
as := assert.New(t)

Expand All @@ -35,10 +49,17 @@ func Test_AI(t *testing.T) {
Text: "Some checks haven’t completed yet",
})
printData(resp)
if skipIfAIFrequencyLimited(t, err) {
return
}
as.Nil(err)
as.NotNil(resp)
if !as.NotNil(resp) {
return
}
as.Equal("en", strings.ToLower(resp.Language))
as.NotEmpty(response.LogID)
if response != nil {
as.NotEmpty(response.LogID)
}
})

t.Run("", func(t *testing.T) {
Expand All @@ -49,10 +70,17 @@ func Test_AI(t *testing.T) {
Glossary: nil,
})
printData(resp)
if skipIfAIFrequencyLimited(t, err) {
return
}
as.Nil(err)
as.NotNil(resp)
if !as.NotNil(resp) {
return
}
as.Contains([]string{"country", "national"}, strings.ToLower(resp.Text))
as.NotEmpty(response.LogID)
if response != nil {
as.NotEmpty(response.LogID)
}
})

t.Run("", func(t *testing.T) {
Expand All @@ -61,8 +89,13 @@ func Test_AI(t *testing.T) {
Image: &runImageText,
})
printData(resp)
if skipIfAIFrequencyLimited(t, err) {
return
}
as.Nil(err)
as.NotNil(resp)
if !as.NotNil(resp) {
return
}
as.Len(resp.TextList, 1)
as.Equal("Run", resp.TextList[0])
})
Expand All @@ -73,8 +106,13 @@ func Test_AI(t *testing.T) {
Image: &runImageText,
})
printData(resp)
if skipIfAIFrequencyLimited(t, err) {
return
}
as.Nil(err)
as.NotNil(resp)
if !as.NotNil(resp) {
return
}
as.Len(resp.TextList, 1)
as.Equal("Run", resp.TextList[0])
})
Expand Down
68 changes: 34 additions & 34 deletions test/application_sample_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/drive_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func Test_DriveFile(t *testing.T) {
{
resp, _, err := AppAllPermission.Ins().Drive.DownloadDriveFile(ctx, &lark.DownloadDriveFileReq{
FileToken: fileToken,
Range: [2]int64{},
})
as.Nil(err)
as.NotNil(resp)
Expand Down
Loading
Loading