{"modulePath":"github.com/stackpointcloud/packer","version":"v0.10.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package testing\n\n## Constants\n\n```go\nconst TestEnvVar = \"PACKER_ACC\"\n```\nTestEnvVar must be set to a non-empty value for acceptance tests to run.\n\n## Functions\n\n```go\nfunc Test(t TestT, c TestCase)\n```\nTest performs an acceptance test on a backend with the given test case.\n\nTests are not run unless an environmental variable \"PACKER\\_ACC\" is set to some non-empty value. This is to avoid test cases surprising a user by creating real resources.\n\nTests will fail unless the verbose flag (\\`go test -v\\`, or explicitly the \"-test.v\" flag) is set. Because some acceptance tests take quite long, we require the verbose flag so users are able to see progress output.\n\n## Types\n\n```go\ntype TestCase struct {\n\t// Precheck, if non-nil, will be called once before the test case\n\t// runs at all. This can be used for some validation prior to the\n\t// test running.\n\tPreCheck func()\n\n\t// Builder is the Builder that will be tested. It will be available\n\t// as the \"test\" builder in the template.\n\tBuilder packer.Builder\n\n\t// Template is the template contents to use.\n\tTemplate string\n\n\t// Check is called after this step is executed in order to test that\n\t// the step executed successfully. If this is not set, then the next\n\t// step will be called\n\tCheck TestCheckFunc\n\n\t// Teardown will be called before the test case is over regardless\n\t// of if the test succeeded or failed. This should return an error\n\t// in the case that the test can't guarantee all resources were\n\t// properly cleaned up.\n\tTeardown TestTeardownFunc\n\n\t// If SkipArtifactTeardown is true, we will not attempt to destroy the\n\t// artifact created in this test run.\n\tSkipArtifactTeardown bool\n}\n```\nTestCase is a single set of tests to run for a backend. A TestCase should generally map 1:1 to each test method for your acceptance tests.\n\n```go\ntype TestCheckFunc func([]packer.Artifact) error\n```\nTestCheckFunc is the callback used for Check in TestStep.\n\n```go\ntype TestT interface {\n\tError(args ...interface{})\n\tFatal(args ...interface{})\n\tSkip(args ...interface{})\n}\n```\nTestT is the interface used to handle the test lifecycle of a test.\n\nUsers should just use a \\*testing.T object, which implements this.\n\n```go\ntype TestTeardownFunc func() error\n```\nTestTeardownFunc is the callback used for Teardown in TestCase.\n\n","path":"github.com/stackpointcloud/packer/helper/builder/testing","name":"testing","synopsis":"","isRedistributable":true}
