Dagger
Search

gotest

No long description provided.

Installation

dagger install github.com/Excoriate/daggerverse/gotest@v1.19.0

Entrypoint

Return Type
Gotest !
Arguments
NameTypeDescription
versionString version is the version of the GoReleaser to use, e.g., "v1.22.0".
imageString image is the image to use as the base container.
ctrContainer Ctrl is the container to use as a base container.
envVarsFromHostString EnvVarsFromHost is a list of environment variables to pass from the host to the container. Later on, in order to pass it to the container, it's going to be converted into a map.
Example
func (m *myModule) example() *Gotest  {
	return dag.
			Gotest()
}
@function
def example() -> dag.Gotest:
	return (
		dag.gotest()
	)
@func()
example(): Gotest {
	return dag
		.gotest()
}

Types

Gotest 🔗

Gotest is a module that provides functionality to run Go tests. The module can be used to run tests in a Go project.

src() 🔗

Src is the directory that contains all the source code, including the module directory.

Return Type
Directory !
Example
func (m *myModule) example() *Directory  {
	return dag.
			Gotest().
			Src()
}
@function
def example() -> dagger.Directory:
	return (
		dag.gotest()
		.src()
	)
@func()
example(): Directory {
	return dag
		.gotest()
		.src()
}

ctr() 🔗

Ctr is the container to use as a base container.

Return Type
Container !
Example
func (m *myModule) example() *Container  {
	return dag.
			Gotest().
			Ctr()
}
@function
def example() -> dagger.Container:
	return (
		dag.gotest()
		.ctr()
	)
@func()
example(): Container {
	return dag
		.gotest()
		.ctr()
}

base() 🔗

Base sets the base image and version, and creates the base container. The default image is “golang/alpine” and the default version is “latest”.

Return Type
Gotest !
Arguments
NameTypeDefault ValueDescription
imageUrlString !-No description provided
Example
func (m *myModule) example(imageUrl string) *Gotest  {
	return dag.
			Gotest().
			Base(imageUrl)
}
@function
def example(image_url: str) -> dag.Gotest:
	return (
		dag.gotest()
		.base(image_url)
	)
@func()
example(imageUrl: string): Gotest {
	return dag
		.gotest()
		.base(imageUrl)
}

withSource() 🔗

WithSource Set the source directory.

Return Type
Gotest !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-Src is the directory that contains all the source code, including the module directory.
workdirString -workdir is the working directory.
Example
func (m *myModule) example(src *Directory) *Gotest  {
	return dag.
			Gotest().
			WithSource(src)
}
@function
def example(src: dagger.Directory) -> dag.Gotest:
	return (
		dag.gotest()
		.with_source(src)
	)
@func()
example(src: Directory): Gotest {
	return dag
		.gotest()
		.withSource(src)
}

withPlatform() 🔗

WithPlatform Set GOOS, GOARCH and GOARM environment variables.

Return Type
Gotest !
Arguments
NameTypeDefault ValueDescription
platformScalar !-Target platform in "[os]/[platform]/[version]" format (e.g., "darwin/arm64/v7", "windows/amd64", "linux/arm64").
Example
func (m *myModule) example(platform ) *Gotest  {
	return dag.
			Gotest().
			WithPlatform(platform)
}
@function
def example(platform: ) -> dag.Gotest:
	return (
		dag.gotest()
		.with_platform(platform)
	)
@func()
example(platform: ): Gotest {
	return dag
		.gotest()
		.withPlatform(platform)
}

withCgoEnabled() 🔗

WithCgoEnabled Set CGO_ENABLED environment variable to 1.

Return Type
Gotest !
Example
func (m *myModule) example() *Gotest  {
	return dag.
			Gotest().
			WithCgoEnabled()
}
@function
def example() -> dag.Gotest:
	return (
		dag.gotest()
		.with_cgo_enabled()
	)
@func()
example(): Gotest {
	return dag
		.gotest()
		.withCgoEnabled()
}

withCgoDisabled() 🔗

WithCgoDisabled Set CGO_ENABLED environment variable to 0.

Return Type
Gotest !
Example
func (m *myModule) example() *Gotest  {
	return dag.
			Gotest().
			WithCgoDisabled()
}
@function
def example() -> dag.Gotest:
	return (
		dag.gotest()
		.with_cgo_disabled()
	)
@func()
example(): Gotest {
	return dag
		.gotest()
		.withCgoDisabled()
}

withEnvironmentVariable() 🔗

WithEnvironmentVariable Set an environment variable.

Return Type
Gotest !
Arguments
NameTypeDefault ValueDescription
nameString !-The name of the environment variable (e.g., "HOST").
valueString !-The value of the environment variable (e.g., "localhost").
expandBoolean -Replace `${VAR}` or $VAR in the value according to the current environment variables defined in the container (e.g., "/opt/bin:$PATH").
Example
func (m *myModule) example(name string, value string) *Gotest  {
	return dag.
			Gotest().
			WithEnvironmentVariable(name, value)
}
@function
def example(name: str, value: str) -> dag.Gotest:
	return (
		dag.gotest()
		.with_environment_variable(name, value)
	)
@func()
example(name: string, value: string): Gotest {
	return dag
		.gotest()
		.withEnvironmentVariable(name, value)
}

withModuleCache() 🔗

WithModuleCache sets the module cache for the Go module. The default cache volume is “godmodcache”, and the default mount path is “/go/pkg/mod”.

Return Type
Gotest !
Example
func (m *myModule) example() *Gotest  {
	return dag.
			Gotest().
			WithModuleCache()
}
@function
def example() -> dag.Gotest:
	return (
		dag.gotest()
		.with_module_cache()
	)
@func()
example(): Gotest {
	return dag
		.gotest()
		.withModuleCache()
}

withBuildCache() 🔗

WithBuildCache sets the build cache for the Go module. The default cache volume is “gobuildcache”, and the default mount path is “/go/build-cache”.

Return Type
Gotest !
Example
func (m *myModule) example() *Gotest  {
	return dag.
			Gotest().
			WithBuildCache()
}
@function
def example() -> dag.Gotest:
	return (
		dag.gotest()
		.with_build_cache()
	)
@func()
example(): Gotest {
	return dag
		.gotest()
		.withBuildCache()
}

withGoCache() 🔗

WithGoCache mounts the Go cache directories.

Return Type
Gotest !
Example
func (m *myModule) example() *Gotest  {
	return dag.
			Gotest().
			WithGoCache()
}
@function
def example() -> dag.Gotest:
	return (
		dag.gotest()
		.with_go_cache()
	)
@func()
example(): Gotest {
	return dag
		.gotest()
		.withGoCache()
}

withNewNetrcFileGitHub() 🔗

WithNewNetrcFileGitHub creates a new .netrc file with the GitHub credentials.

The .netrc file is created in the root directory of the container.

Return Type
Gotest !
Arguments
NameTypeDefault ValueDescription
usernameString !-No description provided
passwordString !-No description provided
Example
func (m *myModule) example(username string, password string) *Gotest  {
	return dag.
			Gotest().
			WithNewNetrcFileGitHub(username, password)
}
@function
def example(username: str, password: str) -> dag.Gotest:
	return (
		dag.gotest()
		.with_new_netrc_file_git_hub(username, password)
	)
@func()
example(username: string, password: string): Gotest {
	return dag
		.gotest()
		.withNewNetrcFileGitHub(username, password)
}

withNewNetrcFileGitLab() 🔗

WithNewNetrcFileGitLab creates a new .netrc file with the GitLab credentials.

The .netrc file is created in the root directory of the container.

Return Type
Gotest !
Arguments
NameTypeDefault ValueDescription
usernameString !-No description provided
passwordString !-No description provided
Example
func (m *myModule) example(username string, password string) *Gotest  {
	return dag.
			Gotest().
			WithNewNetrcFileGitLab(username, password)
}
@function
def example(username: str, password: str) -> dag.Gotest:
	return (
		dag.gotest()
		.with_new_netrc_file_git_lab(username, password)
	)
@func()
example(username: string, password: string): Gotest {
	return dag
		.gotest()
		.withNewNetrcFileGitLab(username, password)
}

withPrivateGoPkg() 🔗

WithPrivateGoPkg sets the GOPRIVATE environment variable.

Return Type
Gotest !
Arguments
NameTypeDefault ValueDescription
privateHostString !-No description provided
Example
func (m *myModule) example(privateHost string) *Gotest  {
	return dag.
			Gotest().
			WithPrivateGoPkg(privateHost)
}
@function
def example(private_host: str) -> dag.Gotest:
	return (
		dag.gotest()
		.with_private_go_pkg(private_host)
	)
@func()
example(privateHost: string): Gotest {
	return dag
		.gotest()
		.withPrivateGoPkg(privateHost)
}

withGcccompiler() 🔗

WithGCCCompiler installs the GCC compiler and musl-dev package.

Return Type
Gotest !
Example
func (m *myModule) example() *Gotest  {
	return dag.
			Gotest().
			WithGcccompiler()
}
@function
def example() -> dag.Gotest:
	return (
		dag.gotest()
		.with_gcccompiler()
	)
@func()
example(): Gotest {
	return dag
		.gotest()
		.withGcccompiler()
}

withGoTestSum() 🔗

WithGoTestSum installs the gotestsum CLI.

Return Type
Gotest !
Example
func (m *myModule) example() *Gotest  {
	return dag.
			Gotest().
			WithGoTestSum()
}
@function
def example() -> dag.Gotest:
	return (
		dag.gotest()
		.with_go_test_sum()
	)
@func()
example(): Gotest {
	return dag
		.gotest()
		.withGoTestSum()
}

withGitInstalled() 🔗

WithGitInstalled installs the Git version control system in the target container.

This method is equivalent to running apk add --no-cache git on an Alpine-based container. It modifies the container instance by adding Git, thus making Git available for any subsequent operations within the container.

Usage example:

gotestInstance := &Gotest{}
gotestInstance = gotestInstance.WithGitInstalled()

Returns the modified Gotest instance.

Return Type
Gotest !
Example
func (m *myModule) example() *Gotest  {
	return dag.
			Gotest().
			WithGitInstalled()
}
@function
def example() -> dag.Gotest:
	return (
		dag.gotest()
		.with_git_installed()
	)
@func()
example(): Gotest {
	return dag
		.gotest()
		.withGitInstalled()
}

runGoTest() 🔗

RunGoTest runs tests using the go test CLI. The default packages to test are “./…”.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-The directory containing code to test.
packages[String ! ] -Packages to test.
enableVerboseBoolean -enableVerbose is a flag to run tests with -v.
raceBoolean -race is a flag to run tests with
testFlags[String ! ] -Arbitrary flags to pass along to go test.
insecureRootCapabilitiesBoolean -Whether to run tests insecurely, i.e. with special privileges.
nestBoolean -Enable experimental Dagger nesting.
enableCacheBoolean -enableCache is a flag to enable cache volumes.
envVars[String ! ] -No description provided
printEnvVarsBoolean -printEnvVars is a flag to print the environment variables
Example
func (m *myModule) example(ctx context.Context, src *Directory) string  {
	return dag.
			Gotest().
			RunGoTest(ctx, src)
}
@function
async def example(src: dagger.Directory) -> str:
	return await (
		dag.gotest()
		.run_go_test(src)
	)
@func()
async example(src: Directory): Promise<string> {
	return dag
		.gotest()
		.runGoTest(src)
}

runGoTestSum() 🔗

RunGoTestSum runs tests using the gotestsum CLI.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-The directory containing code to test.
packages[String ! ] -Packages to test.
testFlags[String ! ] -Arbitrary flags to pass along to go test.
goTestSumFlags[String ! ] -goTestSumFlags is a flag to pass along to go test -json.
formatString -format defines the option for the GoTestsum format to display
insecureRootCapabilitiesBoolean -Whether to run tests insecurely, i.e. with special privileges.
enableNestBoolean -Enable experimental Dagger nesting. It sets the ExperimentalPrivilegedNesting option in Dagger.
enableCacheBoolean -enableCache is a flag to enable cache volumes. If it's set, it'll enable the cache volumes for the Go module and build cache.
enablePrettyBoolean -enablePretty is a flag to enable pretty output.
envVars[String ! ] -envVars list of environment variables to set in the container with format "SOMETHING=SOMETHING,SOMETHING=SOMETHING".
printEnvVarsBoolean -printEnvVars is a flag to print the environment variables
Example
func (m *myModule) example(ctx context.Context, src *Directory) string  {
	return dag.
			Gotest().
			RunGoTestSum(ctx, src)
}
@function
async def example(src: dagger.Directory) -> str:
	return await (
		dag.gotest()
		.run_go_test_sum(src)
	)
@func()
async example(src: Directory): Promise<string> {
	return dag
		.gotest()
		.runGoTestSum(src)
}

setupGoTest() 🔗

SetupGoTest sets up the go test options, to either evaluate the container and run the test, or return the container to be evaluated later.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-The directory containing code to test.
packages[String ! ] -Packages to test.
enableVerboseBoolean -enableVerbose is a flag to run tests with -v.
raceBoolean -race is a flag to run tests with
testFlags[String ! ] -Arbitrary flags to pass along to go test.
insecureRootCapabilitiesBoolean -Whether to run tests insecurely, i.e. with special privileges.
enableNestBoolean -Enable experimental Dagger nesting. It sets the ExperimentalPrivilegedNesting option in Dagger.
enableCacheBoolean -enableCache is a flag to enable cache volumes. If it's set, it'll enable the cache volumes for the Go module and build cache.
envVars[String ! ] -envVars is a list of environment variables with the format "SOMETHING=SOMETHING,SOMETHING=SOMETHING".
printEnvVarsBoolean -printEnvVars is a flag to print the environment variables
Example
func (m *myModule) example(src *Directory) *Container  {
	return dag.
			Gotest().
			SetupGoTest(src)
}
@function
def example(src: dagger.Directory) -> dagger.Container:
	return (
		dag.gotest()
		.setup_go_test(src)
	)
@func()
example(src: Directory): Container {
	return dag
		.gotest()
		.setupGoTest(src)
}

setupGoTestSum() 🔗

SetupGoTestSum sets up the go test options, to either evaluate the container and run the test, or return the container to be evaluated later.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-The directory containing code to test.
packages[String ! ] -Packages to test.
testFlags[String ! ] -Arbitrary flags to pass along to go test.
goTestSumFlags[String ! ] -goTestSumFlags is a flag to pass along to go test -json.
formatString -format defines the option for the GoTestsum format to display
insecureRootCapabilitiesBoolean -Whether to run tests insecurely, i.e. with special privileges.
enableNestBoolean -Enable experimental Dagger nesting. It sets the ExperimentalPrivilegedNesting option in Dagger.
enableCacheBoolean -enableCache is a flag to enable cache volumes. If it's set, it'll enable the cache volumes for the Go module and build cache.
enablePrettyBoolean -enablePretty is a flag to enable pretty output.
envVars[String ! ] -envVars is a list of environment variables to set with the format "SOMETHING=SOMETHING,SOMETHING=SOMETHING".
printEnvVarsBoolean -printEnvVars is a flag to print the environment variables
Example
func (m *myModule) example(src *Directory) *Container  {
	return dag.
			Gotest().
			SetupGoTestSum(src)
}
@function
def example(src: dagger.Directory) -> dagger.Container:
	return (
		dag.gotest()
		.setup_go_test_sum(src)
	)
@func()
example(src: Directory): Container {
	return dag
		.gotest()
		.setupGoTestSum(src)
}