Skip to content

Commit

Permalink
golang lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vearne committed May 13, 2024
1 parent 1f72d0a commit a16801a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/golang-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand All @@ -34,7 +32,6 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: build broker
run: go build -o chat-broker ./cmd/broker
- name: build logic
run: go build -o chat-logic ./cmd/logic
- name: build
run: go build -o autotest ./

1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ run:
- test
- example
- cmd
- docker-compose
1 change: 1 addition & 0 deletions internal/command/http_automate.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func HandleSingleFile(workerNum int, filePath string) *ResultInfo {
}

finishCount++
//nolint: errcheck
bar.Percent(float64(finishCount) / float64(len(testcases)) * 100)
if finishCount >= len(testcases) {
// finish all test cases
Expand Down
8 changes: 4 additions & 4 deletions internal/command/http_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ func (m *HttpTestCallable) Call(ctx context.Context) *executor.GPResult {
return &r
}

ctx, cancel := context.WithTimeout(context.Background(), resource.GlobalConfig.Global.RequestTimeout)
timeout := resource.GlobalConfig.Global.RequestTimeout
rCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

in := resource.RestyClient.R().SetContext(ctx)
in := resource.RestyClient.R().SetContext(rCtx)
for _, item := range req.Headers {
strList := strings.Split(item, ":")
in.SetHeader(strings.TrimSpace(strList[0]), strings.TrimSpace(strList[1]))
Expand Down Expand Up @@ -125,9 +126,8 @@ func (m *HttpTestCallable) Call(ctx context.Context) *executor.GPResult {
}

// verify
VerifyResult := true
for idx, rule := range m.testcase.VerifyRules {
VerifyResult = rule.Verify(out)
VerifyResult := rule.Verify(out)
if !VerifyResult {
zaplog.Error("HttpTestCallable rules validate failed",
zap.Uint64("testCaseId", m.testcase.ID),
Expand Down
6 changes: 3 additions & 3 deletions internal/rule/http_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestHttpBodyAtLeastOneRule(t *testing.T) {
resp.SetBody([]byte(jsonStr1))
for _, item := range cases {
rule := HttpBodyAtLeastOneRule{item.xpath, item.expected}
assert.True(t, rule.Valid(&resp))
assert.True(t, rule.Verify(&resp))
}
}

Expand All @@ -36,7 +36,7 @@ func TestHttpBodyEqualRule(t *testing.T) {
resp.SetBody([]byte(jsonStr1))
for _, item := range cases {
rule := HttpBodyEqualRule{item.xpath, item.expected}
assert.True(t, rule.Valid(&resp))
assert.True(t, rule.Verify(&resp))
}

}
Expand All @@ -55,6 +55,6 @@ func TestHttpBodyEqualRule2(t *testing.T) {
resp.SetBody([]byte(jsonStr2))
for _, item := range cases {
rule := HttpBodyEqualRule{item.xpath, item.expected}
assert.True(t, rule.Valid(&resp))
assert.True(t, rule.Verify(&resp))
}
}

0 comments on commit a16801a

Please sign in to comment.