Skip to content

docs site: quick start - parameters and test case outdated code #1447

@GlenDC

Description

@GlenDC

Description

Code snippet for smallbrain/bigbrain main.go file seems to be out of date,
this code and explanation is found at https://docs.testground.ai/writing-test-plans/paramaters-and-testcases.

What defines this endeavour to be complete?

Documentation is updated with correct snippets.

Proposed Fixes

The following snippet is a version that does seem to work:

package main

import (
	"github.com/testground/sdk-go/run"
	"github.com/testground/sdk-go/runtime"
)

var testcases = map[string]interface{}{
	"bigbrain":   run.InitializedTestCaseFn(runTestCase),
	"smallbrain": run.InitializedTestCaseFn(runTestCase),
}

func main() {
	run.InvokeMap(testcases)
}

func runTestCase(runenv *runtime.RunEnv, initCtx *run.InitContext) error {
	var (
		num     = runenv.IntParam("num")
		word    = runenv.StringParam("word")
		feature = runenv.BooleanParam("feature")
	)

	runenv.RecordMessage("I am a %s test case.", runenv.TestCase)
	runenv.RecordMessage("I store my files on %d servers.", num)
	runenv.RecordMessage("I %s run tests on my P2P code.", word)

	if feature {
		runenv.RecordMessage("I use IPFS!")
	}

	return nil
}

Note that besides this I also had to:

  • update my go.mod file and rename the module (e.g. testground-tutorial)
    • mentioning it here as I do not see this instruction mentioned anywhere in the tutorial page
  • After this I had to run go mod tidy

Doing all this does make the following command work:

testground run single --plan quickstart \
                        --testcase smallbrain \
                        --builder exec:go \
                        --runner local:exec \
                        --instances 1

Adding this issue here as that is what your instructions seem to request at the start of your docs.
If you wish I can also contribute it msyelf.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions