Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Jun 13, 2024
1 parent 8ffcc0f commit b5840d0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ jobs:
with:
go-version: 1.22

- uses: docker/setup-qemu-action@v2
- uses: docker/setup-qemu-action@v3

- uses: actions/checkout@v4

- run: go run ./lib/docker $GITHUB_REF
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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-other-platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions lib/cdp/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 16 additions & 0 deletions lib/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"image"
"image/jpeg"
"image/png"
"os/exec"
"path/filepath"
"testing"
"time"
Expand All @@ -17,6 +18,10 @@ import (

var setup = got.Setup(nil)

func TestNoop(_ *testing.T) {
utils.Noop()
}

func TestTestLog(t *testing.T) {
g := setup(t)

Expand Down Expand Up @@ -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")
}

0 comments on commit b5840d0

Please sign in to comment.