Skip to content

Commit

Permalink
Make init context error message consistent with other usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed May 20, 2021
1 parent be7492b commit 0dd01d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions js/modules/k6/execution/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func New() *Execution {
func (e *Execution) GetVUStats(ctx context.Context) (map[string]interface{}, error) {
vuState := lib.GetState(ctx)
if vuState == nil {
return nil, errors.New("VU information can only be returned from an exported function")
return nil, errors.New("getting VU information in the init context is not supported")
}

scID, _ := vuState.GetScenarioVUID()
Expand All @@ -57,7 +57,7 @@ func (e *Execution) GetVUStats(ctx context.Context) (map[string]interface{}, err
func (e *Execution) GetScenarioStats(ctx context.Context) (map[string]interface{}, error) {
ss := lib.GetScenarioState(ctx)
if ss == nil {
return nil, errors.New("scenario information can only be returned from an exported function")
return nil, errors.New("getting scenario information in the init context is not supported")
}

progress, _ := ss.ProgressFn()
Expand All @@ -79,7 +79,7 @@ func (e *Execution) GetScenarioStats(ctx context.Context) (map[string]interface{
func (e *Execution) GetTestStats(ctx context.Context) (map[string]interface{}, error) {
es := lib.GetExecutionState(ctx)
if es == nil {
return nil, errors.New("test information can only be returned from an exported function")
return nil, errors.New("getting test information in the init context is not supported")
}

out := map[string]interface{}{
Expand Down
6 changes: 3 additions & 3 deletions js/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,7 @@ func TestExecutionStats(t *testing.T) {
{"vu_err", `
var exec = require('k6/execution');
exec.getVUStats();
`, "VU information can only be returned from an exported function"},
`, "getting VU information in the init context is not supported"},
{"scenario_ok", `
var exec = require('k6/execution');
var sleep = require('k6').sleep;
Expand All @@ -2057,7 +2057,7 @@ func TestExecutionStats(t *testing.T) {
{"scenario_err", `
var exec = require('k6/execution');
exec.getScenarioStats();
`, "scenario information can only be returned from an exported function"},
`, "getting scenario information in the init context is not supported"},
{"test_ok", `
var exec = require('k6/execution');
Expand All @@ -2071,7 +2071,7 @@ func TestExecutionStats(t *testing.T) {
{"test_err", `
var exec = require('k6/execution');
exec.getTestStats();
`, "test information can only be returned from an exported function"},
`, "getting test information in the init context is not supported"},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 0dd01d1

Please sign in to comment.