From b5840d0a859514bcc9705e1ef9499d67e981a4f4 Mon Sep 17 00:00:00 2001 From: Yad Smood Date: Thu, 13 Jun 2024 17:08:24 +0800 Subject: [PATCH] fix: test --- .github/workflows/docker.yml | 8 ++++---- .github/workflows/test-linux.yml | 4 ++-- .github/workflows/test-other-platforms.yml | 4 ++-- lib/cdp/websocket_test.go | 6 ++++-- lib/utils/utils_test.go | 16 ++++++++++++++++ 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 46b7b95b..315f4faf 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,7 +20,7 @@ jobs: with: go-version: 1.22 - - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-qemu-action@v3 - uses: actions/checkout@v4 @@ -28,12 +28,12 @@ jobs: env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: review-fonts-docker path: tmp/fonts.pdf - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: cdp-log-docker @@ -47,7 +47,7 @@ jobs: with: go-version: 1.22 - - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-qemu-action@v3 - uses: actions/checkout@v4 diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index 06240fa5..c41a3a26 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -23,11 +23,11 @@ jobs: - run: go generate - - run: go run ./lib/utils/ci-test -race -coverprofile=coverage.out ./... + - run: go run ./lib/utils/ci-test -race -coverprofile=coverage.out . ./lib/utils ./lib/proto ./lib/cdp ./lib/defaults ./lib/devices ./lib/launcher ./lib/input - run: go run github.com/ysmood/got/cmd/check-cov@latest - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: cdp-log-linux diff --git a/.github/workflows/test-other-platforms.yml b/.github/workflows/test-other-platforms.yml index a0eebaf4..2965a372 100644 --- a/.github/workflows/test-other-platforms.yml +++ b/.github/workflows/test-other-platforms.yml @@ -20,7 +20,7 @@ jobs: - run: go run ./lib/utils/ci-test -timeout-each=2m - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: cdp-log-macos @@ -38,7 +38,7 @@ jobs: - run: go run ./lib/utils/ci-test -timeout-each=2m - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: cdp-log-windows diff --git a/lib/cdp/websocket_test.go b/lib/cdp/websocket_test.go index ddcb9695..92e3eada 100644 --- a/lib/cdp/websocket_test.go +++ b/lib/cdp/websocket_test.go @@ -22,12 +22,14 @@ func TestWebSocketLargePayload(t *testing.T) { ctx := g.Context() client, id := newPage(ctx, g) + const size = 2 * 1024 * 1024 + res, err := client.Call(ctx, id, "Runtime.evaluate", map[string]interface{}{ - "expression": fmt.Sprintf(`"%s"`, strings.Repeat("a", 2*1024*1024)), + "expression": fmt.Sprintf(`"%s"`, strings.Repeat("a", size)), "returnByValue": true, }) g.E(err) - g.Gt(res, 2*1024*1024) // 2MB + g.Gt(len(res), size) // 2MB } func ConcurrentCall(t *testing.T) { diff --git a/lib/utils/utils_test.go b/lib/utils/utils_test.go index 2e92d643..068e1a07 100644 --- a/lib/utils/utils_test.go +++ b/lib/utils/utils_test.go @@ -7,6 +7,7 @@ import ( "image" "image/jpeg" "image/png" + "os/exec" "path/filepath" "testing" "time" @@ -17,6 +18,10 @@ import ( var setup = got.Setup(nil) +func TestNoop(_ *testing.T) { + utils.Noop() +} + func TestTestLog(t *testing.T) { g := setup(t) @@ -252,3 +257,14 @@ func TestCropImage(t *testing.T) { g.E(jpeg.Encode(bin, img, &jpeg.Options{Quality: 80})) g.E(utils.CropImage(bin.Bytes(), 0, 10, 10, 30, 30)) } + +func TestUseNode(t *testing.T) { + g := setup(t) + + utils.UseNode(false) + + p, err := exec.LookPath("npx") + g.E(err) + + g.Has(p, "v20") +}