Skip to content

Commit 8e34dba

Browse files
authored
feat: support to show the error count as summary in report (#305)
Co-authored-by: rick <[email protected]>
1 parent b3c0a9a commit 8e34dba

File tree

21 files changed

+63
-217
lines changed

21 files changed

+63
-217
lines changed

.github/testing/trpc.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/build.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Set up Go
1414
uses: actions/setup-go@v4
1515
with:
16-
go-version: 1.19.x
16+
go-version: 1.20.x
1717
- name: Unit Test
1818
run: |
1919
make test-all-backend test-operator
@@ -45,7 +45,7 @@ jobs:
4545
- name: Set up Go
4646
uses: actions/setup-go@v4
4747
with:
48-
go-version: 1.19.x
48+
go-version: 1.20.x
4949
- name: API Test
5050
env:
5151
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -70,7 +70,7 @@ jobs:
7070
- name: Set up Go
7171
uses: actions/setup-go@v4
7272
with:
73-
go-version: 1.19.x
73+
go-version: 1.20.x
7474
- name: Run GoReleaser
7575
uses: goreleaser/goreleaser-action@v4
7676
env:
@@ -91,7 +91,7 @@ jobs:
9191
- name: Set up Go
9292
uses: actions/setup-go@v4
9393
with:
94-
go-version: 1.19.x
94+
go-version: 1.20.x
9595
- name: Set output
9696
id: vars
9797
run: echo "tag=$(git describe --tags)" >> $GITHUB_OUTPUT
@@ -126,7 +126,7 @@ jobs:
126126
- name: Set up Go
127127
uses: actions/setup-go@v4
128128
with:
129-
go-version: 1.19.x
129+
go-version: 1.20.x
130130
- name: Use Node.js
131131
uses: actions/setup-node@v3
132132
with:

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up Go
2525
uses: actions/setup-go@v4
2626
with:
27-
go-version: 1.19
27+
go-version: 1.20
2828
- name: Use Node.js
2929
uses: actions/setup-node@v3
3030
with:
@@ -46,7 +46,7 @@ jobs:
4646
- name: Set up Go
4747
uses: actions/setup-go@v4
4848
with:
49-
go-version: 1.19.x
49+
go-version: 1.20.x
5050
- name: Unit Test
5151
run: |
5252
make test-all-backend test-operator

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ COPY console/atest-ui .
55
RUN npm install --ignore-scripts --registry=https://registry.npmmirror.com
66
RUN npm run build-only
77

8-
FROM docker.io/golang:1.19 AS builder
8+
FROM docker.io/golang:1.20 AS builder
99

1010
ARG VERSION
1111
ARG GOPROXY

cmd/run.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package cmd
2626

2727
import (
2828
"context"
29+
"errors"
2930
"fmt"
3031
"io"
3132
"log"
@@ -41,6 +42,7 @@ import (
4142
"github.com/linuxsuren/api-testing/pkg/runner"
4243
"github.com/linuxsuren/api-testing/pkg/runner/monitor"
4344
"github.com/linuxsuren/api-testing/pkg/testing"
45+
"github.com/linuxsuren/api-testing/pkg/util"
4446
fakeruntime "github.com/linuxsuren/go-fake-runtime"
4547
"github.com/spf13/cobra"
4648
"github.com/spf13/pflag"
@@ -320,6 +322,7 @@ func (o *runOption) runSuite(loader testing.Loader, dataContext map[string]inter
320322
return
321323
}
322324

325+
var errs []error
323326
suiteRunner := runner.GetTestSuiteRunner(testSuite)
324327
suiteRunner.WithTestReporter(o.reporter)
325328
suiteRunner.WithSecure(testSuite.Spec.Secure)
@@ -343,15 +346,21 @@ func (o *runOption) runSuite(loader testing.Loader, dataContext map[string]inter
343346
ctxWithTimeout, _ := context.WithTimeout(ctx, o.requestTimeout)
344347
ctxWithTimeout = context.WithValue(ctxWithTimeout, runner.ContextKey("").ParentDir(), loader.GetContext())
345348

346-
if output, err = suiteRunner.RunTestCase(&testCase, dataContext, ctxWithTimeout); err != nil && !o.requestIgnoreError {
347-
err = fmt.Errorf("failed to run '%s', %v", testCase.Name, err)
348-
return
349-
} else {
350-
err = nil
349+
output, err = suiteRunner.RunTestCase(&testCase, dataContext, ctxWithTimeout)
350+
if err = util.ErrorWrap(err, "failed to run '%s', %v", testCase.Name, err); err != nil {
351+
if o.requestIgnoreError {
352+
errs = append(errs, err)
353+
} else {
354+
return
355+
}
351356
}
352357
}
353358
dataContext[testCase.Name] = output
354359
}
360+
361+
if len(errs) > 0 {
362+
err = errors.Join(errs...)
363+
}
355364
return
356365
}
357366

cmd/run_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ func TestRunCommand(t *testing.T) {
171171
prepare: fooPrepare,
172172
args: []string{"-p", "[]]$#%*^&()"},
173173
hasErr: true,
174+
}, {
175+
name: "request-ignore-error",
176+
prepare: func() {
177+
gock.New(urlFoo).Get("/bar").Reply(http.StatusBadRequest)
178+
},
179+
args: []string{"-p", simpleSuite, "--request-ignore-error"},
180+
hasErr: true,
174181
}}
175182
for _, tt := range tests {
176183
t.Run(tt.name, func(t *testing.T) {

extensions/collector/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/linuxsuren/api-testing/extensions/collector
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819

extensions/monitor-docker/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/linuxsuren/api-testing/extensions/monitor-docker
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
github.com/docker/cli v24.0.7+incompatible

extensions/store-etcd/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/linuxsuren/api-testing/extensions/store-etcd
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
github.com/linuxsuren/api-testing v0.0.0-00010101000000-000000000000

extensions/store-git/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/linuxsuren/api-testing/extensions/store-git
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
github.com/go-git/go-git/v5 v5.8.1

0 commit comments

Comments
 (0)