Skip to content

Commit

Permalink
Merge pull request #2 from szkiba/feature/initial
Browse files Browse the repository at this point in the history
Feature/initial
  • Loading branch information
szkiba authored Jun 8, 2023
2 parents 661408f + 7c462ec commit 34c9d84
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ linters:
- sqlclosecheck
- wastedassign
run:
timeout: 10m
skip-files:
- "doc.go"
- "example_.*test.go"
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ The go script should be put in the `main` package. The following lifecycle callb

The return values of the lifecycle callback functions are optional, they can also be defined without a return value. The function parameters are also optional, but their order is fixed.

The script is executed similarly to the JavaScript language:

```bash
./k6 run scripts/simple/script.go
```

### Setup

`Setup` function corresponds to the [setup function](https://k6.io/docs/using-k6/test-lifecycle/#setup-and-teardown-stages) of the JavaScript API.
Expand Down Expand Up @@ -142,7 +148,7 @@ var Options map[string]interface{}
The xk6-g0 is currently in Proof of Concept status. The further fate of the development depends on the community's feedback on the usefulness of the concept.

**Is it useful to support the go language (yaegi interpreter) in k6 tests?**
You can vote here: TBD
You can vote here: https://github.com/szkiba/xk6-g0/discussions/1

## API

Expand Down Expand Up @@ -328,13 +334,13 @@ You can also use pre-built k6 image within a Docker container. In order to do th
**Linux**

```plain
docker run -v $(pwd):/scripts -it --rm ghcr.io/szkiba/xk6-g0:latest run --out=dashboard /scripts/script.js
docker run -v $(pwd):/work -it --rm ghcr.io/szkiba/xk6-g0:latest run /work/scripts/simple/script.go
```

**Windows**

```plain
docker run -v %cd%:/scripts -it --rm ghcr.io/szkiba/xk6-g0:latest run --out=dashboard /scripts/script.js
docker run -v %cd%:/work -it --rm ghcr.io/szkiba/xk6-g0:latest run /work/scripts/simple/script.go
```

## Example scripts
Expand Down
3 changes: 1 addition & 2 deletions g0/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"sync/atomic"
"time"

"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.k6.io/k6/js/common"
Expand All @@ -26,7 +25,7 @@ type checker struct {

func (c *checker) Errorf(format string, args ...interface{}) {
state := c.vu.State()
if state == nil || !state.Logger.IsLevelEnabled(logrus.DebugLevel) {
if state == nil {
return
}

Expand Down
2 changes: 0 additions & 2 deletions g0/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package g0
import (
"os"

"github.com/sirupsen/logrus"
"github.com/szkiba/xk6-g0/internal/builtin/testify/assertions"
"github.com/szkiba/xk6-g0/internal/builtin/testify/requirements"
"github.com/traefik/yaegi/interp"
Expand Down Expand Up @@ -135,7 +134,6 @@ func (mod *Module) Exports() modules.Exports {
}

func (mod *Module) callSetup() (interface{}, error) {
logrus.SetLevel(mod.vu.State().Logger.GetLevel())
mod.vu.State().Logger.Debug("Calling Setup")

return mod.setupFunc(mod.vu.Context(), mod.assert, mod.require)
Expand Down

0 comments on commit 34c9d84

Please sign in to comment.