gotest
This Dagger module is tailored for running Go test commands within containerized environments.It enables users to execute Go tests efficiently by defining a base container,
passing environment variables from the host,
and managing container configurations seamlessly. The Gotest module exemplifies how to
leverage Dagger's capabilities
for executing Go tests in various workflows.
Functions in this module can be invoked from the Dagger CLI or through SDKs,
allowing for flexible integration into CI/CD pipelines. This module is designed to be
extensible and adaptable for diverse testing scenarios in Go applications.
Example (OpenTerminal)
no available example in current language
// Gotest_OpenTerminal demonstrates how to open an interactive terminal session
// within a Gotest module container.
//
// This function showcases the initialization and configuration of a
// Gotest module container using various options like enabling Cgo,
// utilizing build cache, and including a GCC compiler.
//
// Parameters:
// - None
//
// Returns:
// - *dagger.Container: A configured Dagger container with an open terminal.
//
// Usage:
//
// This function can be used to interactively debug or inspect the
// container environment during test execution.
func (m *Go) Gotest_OpenTerminal() *dagger.Container {
// Configure the Gotest module container with necessary options
targetModule := dag.Gotest()
// Retrieve and discard standard output
_, _ = targetModule.Ctr().
Stdout(context.Background())
// Open and return the terminal session in the configured container
return targetModule.Ctr().
Terminal()
}
no available example in current language
no available example in current language
Example (PassedEnvVars)
no available example in current language
// Gotest_PassedEnvVars demonstrates how to pass environment variables to the Gotest module.
//
// This method configures a Gotest module to use specific environment variables from the host.
func (m *Go) Gotest_PassedEnvVars(ctx context.Context) error {
targetModule := dag.Gotest(dagger.GotestOpts{
EnvVarsFromHost: []string{"SOMETHING=SOMETHING,SOMETHING=SOMETHING"},
})
out, err := targetModule.Ctr().
WithExec([]string{"printenv"}).
Stdout(ctx)
if err != nil {
return fmt.Errorf("failed when executing printenv: %w", err)
}
if out == "" {
return errEnvVarsEmpty
}
if !strings.Contains(out, "SOMETHING") {
return errEnvVarsDontMatch
}
return nil
}
no available example in current language
no available example in current language
Example (CreateContainer)
no available example in current language
// Gotest_CreateContainer initializes and returns a configured Dagger container.
//
// This method exemplifies the setup of a container within the Gotest module using the source directory.
//
// Parameters:
// - ctx: The context for controlling the function's timeout and cancellation.
//
// Returns:
// - A configured Dagger container if successful, or an error if the process fails.
//
// Steps Involved:
// 1. Configure the Gotest module with the source directory.
// 2. Run a command inside the container to check the OS information.
func (m *Go) Gotest_CreateContainer(ctx context.Context) (*dagger.Container, error) {
targetModule := dag.
Gotest().
Base("alpine:latest").
WithSource(m.TestDir)
// Get the OS or container information
_, err := targetModule.
Ctr().WithExec([]string{"uname"}).
Stdout(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get OS information: %w", err)
}
return targetModule.Ctr(), nil
}
no available example in current language
no available example in current language
Example (RunArbitraryCommand)
no available example in current language
// Gotest_RunArbitraryCommand runs an arbitrary shell command in the test container.
//
// This function demonstrates how to execute a shell command within the container
// using the Gotest module.
//
// Parameters:
//
// ctx - context for controlling the function lifetime.
//
// Returns:
//
// A string containing the output of the executed command, or an error if the command fails or if the output is empty.
func (m *Go) Gotest_RunArbitraryCommand(ctx context.Context) (string, error) {
targetModule := dag.Gotest().WithSource(m.TestDir)
// Execute the 'ls -l' command
out, err := targetModule.
Ctr().
WithExec([]string{"ls", "-l"}).
Stdout(ctx)
if err != nil {
return "", fmt.Errorf("failed to run shell command: %w", err)
}
if out == "" {
return "", errExpectedFoldersNotFound
}
return out, nil
}
no available example in current language
no available example in current language
Installation
dagger install github.com/Excoriate/daggerverse/gotest@v1.3.0
Entrypoint
Return Type
Gotest !
Arguments
Name | Type | Description |
---|---|---|
version | String | version is the version of the GoReleaser to use, e.g., "v1.22.0". Optional parameter. |
image | String | image is the image to use as the base container. Optional parameter. |
ctr | Container | ctr is the container to use as a base container. Optional parameter. |
envVarsFromHost | [String ! ] | envVarsFromHost is a list of environment variables to pass from the host to the container in a slice of strings. Optional parameter. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
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 Dagger module. This module is used to create and manage containers.
ctr() 🔗
Ctr is the container to use as a base container.
Return Type
Container !
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
ctr
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()
}
withGoPlatform() 🔗
WithGoPlatform sets the Go environment variables for the target platform.
platform is the target platform specified in the format “[os]/[platform]/[version]”. For example, “darwin/arm64/v7”, “windows/amd64”, “linux/arm64”. If the platform is not provided, it defaults to “linux/amd64”.
Params: - platform (dagger.Platform): The target platform.
Returns: - *Gotest: A pointer to the updated Gotest instance.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
platform | Scalar | - | platform is the target platform specified in the format "[os]/[platform]/[version]". For example, "darwin/arm64/v7", "windows/amd64", "linux/arm64". If the platform is not provided, it defaults to "linux/amd64". |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-go-platform
func (m *myModule) example() *Gotest {
return dag.
Gotest().
WithGoPlatform()
}
@function
def example() -> dag.Gotest:
return (
dag.gotest()
.with_go_platform()
)
@func()
example(): Gotest {
return dag
.gotest()
.withGoPlatform()
}
withGoCgoEnabled() 🔗
WithGoCgoEnabled enables CGO for the container environment.
When CGO is enabled, the Go toolchain will allow the use of cgo, which means it can link against C libraries and send code to the C compiler.
Returns: - *Gotest: A pointer to the updated Gotest instance.
Return Type
Gotest !
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-go-cgo-enabled
func (m *myModule) example() *Gotest {
return dag.
Gotest().
WithGoCgoEnabled()
}
@function
def example() -> dag.Gotest:
return (
dag.gotest()
.with_go_cgo_enabled()
)
@func()
example(): Gotest {
return dag
.gotest()
.withGoCgoEnabled()
}
withGcccompilerInstalled() 🔗
WithGCCCompilerInstalled installs the GCC compiler and musl-dev package in the container environment using the Alpine package manager (apk).
This method is useful for enabling the Go toolchain to compile C code and link against C libraries, which is necessary for certain Go packages that rely on CGO.
Returns: - *Gotest: A pointer to the updated Gotest instance.
Return Type
Gotest !
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-gcccompiler-installed
func (m *myModule) example() *Gotest {
return dag.
Gotest().
WithGcccompilerInstalled()
}
@function
def example() -> dag.Gotest:
return (
dag.gotest()
.with_gcccompiler_installed()
)
@func()
example(): Gotest {
return dag
.gotest()
.withGcccompilerInstalled()
}
withCgoDisabled() 🔗
WithCgoDisabled disables CGO for the container environment.
When CGO is disabled, the Go toolchain will not permit the use of cgo, which means it will not link against C libraries or send code to the C compiler. This can be beneficial for creating fully static binaries or for environments where C dependencies are not available.
Returns: - *Gotest: A pointer to the updated Gotest instance.
Return Type
Gotest !
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-cgo-disabled
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()
}
withGoBuildCache() 🔗
WithGoBuildCache configures a Go build cache for the container environment.
This method sets up the cache volume for Go build artifacts, which speeds up the build process by reusing previously compiled packages and dependencies.
Params: - cacheRoot (string) +optional: The path to the cache volume’s root. If not provided, it defaults to “/root/.cache/go-build”. - cache (*dagger.CacheVolume) +optional: The cache volume to use. If not provided, a default volume named “gobuildcache” is used. - source (*dagger.Directory) +optional: The directory to use as the source for the cache volume’s root. - sharing (dagger.CacheSharingMode) +optional: The sharing mode of the cache volume. If not provided, it defaults to “shared”.
Returns: - *Gotest: A pointer to the updated Gotest instance.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
cacheRoot | String | - | cacheRoot is the path to the cache volume's root. |
cache | CacheVolume | - | cache is the cache volume to use. |
source | Directory | - | source is the identifier of the directory to use as the cache volume's root. |
sharing | Enum | - | sharing is the Sharing mode of the cache volume. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-go-build-cache
func (m *myModule) example() *Gotest {
return dag.
Gotest().
WithGoBuildCache()
}
@function
def example() -> dag.Gotest:
return (
dag.gotest()
.with_go_build_cache()
)
@func()
example(): Gotest {
return dag
.gotest()
.withGoBuildCache()
}
withGoModCache() 🔗
WithGoModCache configures a Go module cache for the container environment.
This method sets up the cache volume for Go modules, which speeds up the build process by reusing previously downloaded dependencies.
Params: - cacheRoot (string): The path to the cache volume’s root. If not provided, it defaults to “/go/pkg/mod”. - cache (*dagger.CacheVolume) +optional: The cache volume to use. If not provided, a default volume named “gomodcache” is used. - source (*dagger.Directory) +optional: The directory to use as the source for the cache volume’s root. - sharing (dagger.CacheSharingMode) +optional: The sharing mode of the cache volume. If not provided, it defaults to “shared”.
Returns: - *Gotest: A pointer to the updated Gotest instance.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
cacheRoot | String | - | cacheRoot is the path to the cache volume's root. |
cache | CacheVolume | - | cache is the cache volume to use. |
source | Directory | - | source is the identifier of the directory to use as the cache volume's root. |
sharing | Enum | - | sharing is the Sharing mode of the cache volume. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-go-mod-cache
func (m *myModule) example() *Gotest {
return dag.
Gotest().
WithGoModCache()
}
@function
def example() -> dag.Gotest:
return (
dag.gotest()
.with_go_mod_cache()
)
@func()
example(): Gotest {
return dag
.gotest()
.withGoModCache()
}
withGoInstall() 🔗
WithGoInstall installs Go packages in the container environment.
This method uses the Go toolchain to install packages from specified URLs. It performs the equivalent of running “go install [url]” inside the container.
Params:
- pkgs ([]string): A slice of URLs for the Go packages to install. These should be
valid package URLs that the go install
command can use.
Example:
Gotest.WithGoInstall([]string{"github.com/Excoriate/daggerverse@latest",
“github.com/another/package@v1.0”})
Returns: - *Gotest: A pointer to the updated Gotest instance.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
pkgs | [String ! ] ! | - | pkgs are the URLs of the packages to install. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-go-install --pkgs string1 --pkgs string2
func (m *myModule) example(pkgs []string) *Gotest {
return dag.
Gotest().
WithGoInstall(pkgs)
}
@function
def example(pkgs: List[str]) -> dag.Gotest:
return (
dag.gotest()
.with_go_install(pkgs)
)
@func()
example(pkgs: string[]): Gotest {
return dag
.gotest()
.withGoInstall(pkgs)
}
base() 🔗
Base sets the base image for the Gotest module and creates the base container.
Parameters: - imageURL: The URL of the image to use as the base container.
Returns a pointer to the updated Gotest instance.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
imageUrl | String ! | - | No description provided |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
base --image-url string
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)
}
openTerminal() 🔗
OpenTerminal returns a terminal
It returns a terminal for the container. Arguments: - None. Returns: - *Terminal: The terminal for the container.
Return Type
Container !
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
open-terminal
func (m *myModule) example() *Container {
return dag.
Gotest().
OpenTerminal()
}
@function
def example() -> dagger.Container:
return (
dag.gotest()
.open_terminal()
)
@func()
example(): Container {
return dag
.gotest()
.openTerminal()
}
runShell() 🔗
RunShell runs a shell command in the container.
It runs a shell command in the container and returns the output. Arguments: - cmd: The command to run in the container. Returns: - string: The output of the command. - error: An error if the command fails.
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
cmd | String ! | - | No description provided |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
run-shell --cmd string
func (m *myModule) example(ctx context.Context, cmd string) string {
return dag.
Gotest().
RunShell(ctx, cmd)
}
@function
async def example(cmd: str) -> str:
return await (
dag.gotest()
.run_shell(cmd)
)
@func()
async example(cmd: string): Promise<string> {
return dag
.gotest()
.runShell(cmd)
}
downloadFile() 🔗
DownloadFile downloads a file from the specified URL.
Parameters: - url: The URL of the file to download. - destFileName: The name of the file to download. Optional parameter. If not set, it’ll default to the basename of the URL.
Returns: - *dagger.File: The downloaded file.
Functionality:
This method downloads a file from the provided URL. If the destination file name is not specified, it defaults to the basename of the URL. The downloaded file is then returned as a *dagger.File.
Return Type
File !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
url | String ! | - | url is the URL of the file to download. |
destFileName | String | - | destFileName is the name of the file to download. If not set, it'll default to the basename of the URL. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
download-file --url string
func (m *myModule) example(url string) *File {
return dag.
Gotest().
DownloadFile(url)
}
@function
def example(url: str) -> dagger.File:
return (
dag.gotest()
.download_file(url)
)
@func()
example(url: string): File {
return dag
.gotest()
.downloadFile(url)
}
cloneGitRepoHttps() 🔗
CloneGitRepoHTTPS clones a Git repository into a Dagger Directory.
Parameters: - repoURL: The URL of the git repository to clone (e.g., “https://github.com/user/repo”). - token: (Optional) The VCS token to use for authentication. If not provided, the repository will be cloned without authentication. - vcs: (Optional) The version control system (VCS) to use for authentication. Defaults to “github”. Supported values are “github” and “gitlab”. - authHeader: (Optional) The authentication header to use for authentication. If not provided, the repository will be cloned without authentication. - returnDir: (Optional) A string that indicates the directory path of the repository to return. - branch: (Optional) The branch to checkout. If not provided, the default branch will be checked out. - keepGitDir: (Optional) A boolean that indicates if the .git directory should be kept. Defaults to false. - tag: (Optional) The tag to checkout. If not provided, no tag will be checked out. - commit: (Optional) The commit to checkout. If not provided, the latest commit will be checked out.
Returns: - *dagger.Directory: A directory object representing the cloned repository.
If a token is provided, it will be securely set using Dagger’s secret mechanism and used for authentication during the clone operation.
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
repoUrl | String ! | - | repoURL is the URL of the git repo to clone. |
token | Secret | - | token is the VCS token to use for authentication. Optional parameter. |
vcs | String | - | vcs is the VCS to use for authentication. Optional parameter. |
authHeader | Secret | - | authHeader is the authentication header to use for authentication. Optional parameter. |
returnDir | String | - | returnDir is a string that indicates the directory path of the repository to return. |
branch | String | - | branch is the branch to checkout. Optional parameter. |
discardGitDir | Boolean | - | discardGitDir is a boolean that indicates if the .git directory should be discarded. Optional parameter. |
tag | String | - | tag is the tag to checkout. Optional parameter. |
commit | String | - | commit is the commit to checkout. Optional parameter. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
clone-git-repo-https --repo-url string
func (m *myModule) example(repoUrl string) *Directory {
return dag.
Gotest().
CloneGitRepoHttps(repoUrl)
}
@function
def example(repo_url: str) -> dagger.Directory:
return (
dag.gotest()
.clone_git_repo_https(repo_url)
)
@func()
example(repoUrl: string): Directory {
return dag
.gotest()
.cloneGitRepoHttps(repoUrl)
}
cloneGitRepoSsh() 🔗
CloneGitRepoSSH clones a git repository using SSH for authentication. It allows specifying various options such as the branch, tag, or commit to checkout, whether to keep the .git directory, and the directory path of the repository to return.
Parameters:
repoURL: The URL of the git repo to clone.
sshSocket: The SSH socket to use for authentication.
sshKnownHosts: The known hosts to use for authentication. Optional parameter.
returnDir: A string that indicates the directory path of the repository to return. Optional parameter.
branch: The branch to checkout. Optional parameter.
keepGitDir: A boolean that indicates if the .git directory should be kept. Optional parameter.
tag: The tag to checkout. Optional parameter.
commit: The commit to checkout. Optional parameter.
Returns:
*dagger.Directory: The directory of the cloned repository.
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
repoUrl | String ! | - | repoURL is the URL of the git repo to clone. |
sshAuthSocket | Socket ! | - | sshAuthSocket is the SSH socket to use for authentication. |
sshKnownHosts | String | - | sshKnownHosts is the known hosts to use for authentication. Optional parameter. |
returnDir | String | - | returnDir is a string that indicates the directory path of the repository to return. |
branch | String | - | branch is the branch to checkout. Optional parameter. |
discardGitDir | Boolean | - | discardGitDir is a boolean that indicates if the .git directory should be discarded. Optional parameter. |
tag | String | - | tag is the tag to checkout. Optional parameter. |
commit | String | - | commit is the commit to checkout. Optional parameter. |
Example
echo 'Custom types are not supported in shell examples'
func (m *myModule) example(repoUrl string, sshAuthSocket *Socket) *Directory {
return dag.
Gotest().
CloneGitRepoSsh(repoUrl, sshAuthSocket)
}
@function
def example(repo_url: str, ssh_auth_socket: dag.Socket) -> dagger.Directory:
return (
dag.gotest()
.clone_git_repo_ssh(repo_url, ssh_auth_socket)
)
@func()
example(repoUrl: string, sshAuthSocket: Socket): Directory {
return dag
.gotest()
.cloneGitRepoSsh(repoUrl, sshAuthSocket)
}
withEnvironmentVariable() 🔗
WithEnvironmentVariable sets an environment variable in the container.
Parameters:
- name: The name of the environment variable (e.g., “HOST”).
- value: The value of the environment variable (e.g., “localhost”).
- expand: Whether to replace ${VAR}
or \(VAR in the value according to the current
environment variables defined in the container (e.g., "/opt/bin:\)PATH”).
Optional parameter.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
name | String ! | - | name is the name of the environment variable. |
value | String ! | - | value is the value of the environment variable. |
expand | Boolean | - | expand is whether to replace `${VAR}` or $VAR in the value according to the current |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-environment-variable --name string --value string
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)
}
withSource() 🔗
WithSource sets the source directory for the container.
Parameters: - src: The directory that contains all the source code, including the module directory. - workdir: The working directory within the container. Optional parameter.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | src is the directory that contains all the source code, including the module directory. |
workdir | String | - | workdir is the working directory within the container. If not set it'll default to /mnt |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-source --src DIR_PATH
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)
}
withContainer() 🔗
WithContainer sets the container to be used.
Parameters: - ctr: The container to run the command in. If passed, it will override the container set in the Dagger instance.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
ctr | Container ! | - | No description provided |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-container --ctr IMAGE:TAG
func (m *myModule) example(ctr *Container) *Gotest {
return dag.
Gotest().
WithContainer(ctr)
}
@function
def example(ctr: dagger.Container) -> dag.Gotest:
return (
dag.gotest()
.with_container(ctr)
)
@func()
example(ctr: Container): Gotest {
return dag
.gotest()
.withContainer(ctr)
}
withFileMountedInContainer() 🔗
WithFileMountedInContainer adds a file to the container.
Parameters: - file: The file to add to the container. - dest: The destination path in the container. Optional parameter. - owner: The owner of the file. Optional parameter.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
file | File ! | - | No description provided |
dest | String ! | - | No description provided |
owner | String ! | - | No description provided |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-file-mounted-in-container --file file:path --dest string --owner string
func (m *myModule) example(file *File, dest string, owner string) *Gotest {
return dag.
Gotest().
WithFileMountedInContainer(file, dest, owner)
}
@function
def example(file: dagger.File, dest: str, owner: str) -> dag.Gotest:
return (
dag.gotest()
.with_file_mounted_in_container(file, dest, owner)
)
@func()
example(file: File, dest: string, owner: string): Gotest {
return dag
.gotest()
.withFileMountedInContainer(file, dest, owner)
}
withSecretAsEnvVar() 🔗
WithSecretAsEnvVar sets an environment variable in the container using a secret.
Parameters: - name: The name of the environment variable (e.g., “API_KEY”). - secret: The secret containing the value of the environment variable.
Returns: - *Gotest: The updated Gotest with the environment variable set.
Behavior: - The secret value is expanded according to the current environment variables defined in the container.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
name | String ! | - | No description provided |
secret | Secret ! | - | No description provided |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-secret-as-env-var --name string --secret env:MYSECRET
func (m *myModule) example(name string, secret *Secret) *Gotest {
return dag.
Gotest().
WithSecretAsEnvVar(name, secret)
}
@function
def example(name: str, secret: dagger.Secret) -> dag.Gotest:
return (
dag.gotest()
.with_secret_as_env_var(name, secret)
)
@func()
example(name: string, secret: Secret): Gotest {
return dag
.gotest()
.withSecretAsEnvVar(name, secret)
}
withDownloadedFile() 🔗
WithDownloadedFile downloads a file from the specified URL and mounts it in the container.
Parameters: - url: The URL of the file to download. - destDir: The directory within the container where the file will be downloaded. Optional parameter. If not provided, it defaults to the predefined mount prefix.
Returns: - *Gotest: The updated Gotest with the downloaded file mounted in the container.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
url | String ! | - | url is the URL of the file to download. |
destFileName | String | - | destFileName is the name of the file to download. If not set, it'll default to the basename of the URL. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-downloaded-file --url string
func (m *myModule) example(url string) *Gotest {
return dag.
Gotest().
WithDownloadedFile(url)
}
@function
def example(url: str) -> dag.Gotest:
return (
dag.gotest()
.with_downloaded_file(url)
)
@func()
example(url: string): Gotest {
return dag
.gotest()
.withDownloadedFile(url)
}
withClonedGitRepoHttps() 🔗
WithClonedGitRepoHTTPS clones a Git repository and mounts it as a directory in the container.
This method downloads a Git repository and mounts it as a directory in the container. It supports optional authentication tokens for private repositories and can handle both GitHub and GitLab repositories.
Parameters: - repoURL: The URL of the git repository to clone (e.g., “https://github.com/user/repo”). - token: (Optional) The VCS token to use for authentication. If not provided, the repository will be cloned without authentication. - vcs: (Optional) The version control system (VCS) to use for authentication. Defaults to “github”. Supported values are “github” and “gitlab”.
Returns: - *Gotest: The updated Gotest with the cloned repository mounted in the container.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
repoUrl | String ! | - | No description provided |
token | Secret | - | token is the VCS token to use for authentication. Optional parameter. |
vcs | String | - | vcs is the VCS to use for authentication. Optional parameter. |
authHeader | Secret | - | authHeader is the authentication header to use for authentication. Optional parameter. |
returnDir | String | - | returnDir is a string that indicates the directory path of the repository to return. |
branch | String | - | branch is the branch to checkout. Optional parameter. |
discardGitDir | Boolean | - | discardGitDir is a boolean that indicates if the .git directory should be discarded. Optional parameter. |
tag | String | - | tag is the tag to checkout. Optional parameter. |
commit | String | - | commit is the commit to checkout. Optional parameter. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-cloned-git-repo-https --repo-url string
func (m *myModule) example(repoUrl string) *Gotest {
return dag.
Gotest().
WithClonedGitRepoHttps(repoUrl)
}
@function
def example(repo_url: str) -> dag.Gotest:
return (
dag.gotest()
.with_cloned_git_repo_https(repo_url)
)
@func()
example(repoUrl: string): Gotest {
return dag
.gotest()
.withClonedGitRepoHttps(repoUrl)
}
withClonedGitRepoSsh() 🔗
WithClonedGitRepoSSH clones a git repository using SSH for authentication.
Parameters: - repoURL: The URL of the git repository to clone. - sshSocket: The SSH socket to use for authentication. - sshKnownHosts: The known hosts to use for authentication. Optional parameter. - returnDir: A string that indicates the directory path of the repository to return. Optional parameter. - branch: The branch to checkout. Optional parameter. - keepGitDir: A boolean that indicates if the .git directory should be kept. Optional parameter.
Returns: - *Gotest: The updated Gotest with the cloned repository mounted in the container.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
repoUrl | String ! | - | repoURL is the URL of the git repository to clone. |
sshAuthSocket | Socket ! | - | sshAuthSocket is the SSH socket to use for authentication. |
sshKnownHosts | String | - | sshKnownHosts is the known hosts to use for authentication. Optional parameter. |
returnDir | String | - | returnDir is a string that indicates the directory path of the repository to return. Optional parameter. |
branch | String | - | branch is the branch to checkout. Optional parameter. |
discardGitDir | Boolean | - | discardGitDir is a boolean that indicates if the .git directory should be discarded. Optional parameter. |
tag | String | - | tag is the tag to checkout. Optional parameter. |
commit | String | - | commit is the commit to checkout. Optional parameter. |
Example
echo 'Custom types are not supported in shell examples'
func (m *myModule) example(repoUrl string, sshAuthSocket *Socket) *Gotest {
return dag.
Gotest().
WithClonedGitRepoSsh(repoUrl, sshAuthSocket)
}
@function
def example(repo_url: str, ssh_auth_socket: dag.Socket) -> dag.Gotest:
return (
dag.gotest()
.with_cloned_git_repo_ssh(repo_url, ssh_auth_socket)
)
@func()
example(repoUrl: string, sshAuthSocket: Socket): Gotest {
return dag
.gotest()
.withClonedGitRepoSsh(repoUrl, sshAuthSocket)
}
withCacheBuster() 🔗
WithCacheBuster sets a cache-busting environment variable in the container.
This method sets an environment variable “CACHE_BUSTER” with a timestamp value in RFC3339Nano format. This can be useful for invalidating caches by providing a unique value.
Returns: - *Gotest: The updated Gotest with the cache-busting environment variable set.
Return Type
Gotest !
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-cache-buster
func (m *myModule) example() *Gotest {
return dag.
Gotest().
WithCacheBuster()
}
@function
def example() -> dag.Gotest:
return (
dag.gotest()
.with_cache_buster()
)
@func()
example(): Gotest {
return dag
.gotest()
.withCacheBuster()
}
withConfigFile() 🔗
WithConfigFile mounts a configuration file into the container at the specified path.
This method allows you to mount a configuration file into the container at a specified path. If no path is provided, it defaults to a predefined mount prefix from the fixtures package.
Args: - cfgPath (string): The path where the config file will be mounted. If empty, it defaults to fixtures.MntPrefix. +optional - cfgFile (*dagger.File): The config file to be mounted.
Returns: - *Gotest: The updated Gotest with the config file mounted in the container.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
cfgFile | File ! | - | cfgFile is the config file to be mounted. |
cfgPathInCtr | String | - | cfgPathInCtr is the path where the config file will be mounted. |
setEnvVar | String | - | setEnvVar is a string that set an environment variable in the container with the config file path. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-config-file --cfg-file file:path
func (m *myModule) example(cfgFile *File) *Gotest {
return dag.
Gotest().
WithConfigFile(cfgFile)
}
@function
def example(cfg_file: dagger.File) -> dag.Gotest:
return (
dag.gotest()
.with_config_file(cfg_file)
)
@func()
example(cfgFile: File): Gotest {
return dag
.gotest()
.withConfigFile(cfgFile)
}
withCachedDirectory() 🔗
WithCachedDirectory mounts a cache volume in the container.
Parameters: - path: The path in the container where the cache volume will be mounted. - cacheVolume: The cache volume to mount.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
path | String ! | - | path is the path in the container where the cache volume will be mounted. |
enablePrefixWithMountPath | Boolean | - | enablePrefixWithMountPath is whether to enable the prefix with the mount path. |
setEnvVarWithCacheDirValue | String | - | setEnvVarWithCacheDirValue is the value to set the cache directory in the container. |
cacheSharingMode | Enum | - | cacheSharingMode is the sharing mode of the cache volume. |
cacheVolumeRootDir | Directory | - | cacheVolumeRootDir is the root directory of the cache volume. |
cacheVolumeOwner | String | - | cacheVolumeOwner is the owner of the cache volume. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-cached-directory --path string
func (m *myModule) example(path string) *Gotest {
return dag.
Gotest().
WithCachedDirectory(path)
}
@function
def example(path: str) -> dag.Gotest:
return (
dag.gotest()
.with_cached_directory(path)
)
@func()
example(path: string): Gotest {
return dag
.gotest()
.withCachedDirectory(path)
}
withUserAsOwnerOfDirs() 🔗
WithUserAsOwnerOfDirs sets the specified user (and optionally group) as the owner of the given directories within the container.
This method iterates over the provided list of directories and executes the “chown” command within the container to change the ownership of each directory to the specified user (and optionally group).
Parameters: - user: The user to set as the owner of the directories. This should be a valid user within the container. - group: The group to set as the owner of the directories. This is an optional parameter. - dirs: A slice of strings representing the directories to set the owner of. Each directory path should be specified relative to the container’s filesystem.
Returns: - *Terragrunt: The updated Terragrunt instance with the ownership of the specified directories changed.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
user | String ! | - | user is the user to set as the owner of the directories. |
dirs | [String ! ] ! | - | dirs is the directories to set the owner of. |
group | String | - | group is the group to set as the owner of the directories. |
configureAsRoot | Boolean | - | configureAsRoot is whether to configure the directories as root, and then it'll use the given user. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-user-as-owner-of-dirs --user string --dirs string1 --dirs string2
func (m *myModule) example(user string, dirs []string) *Gotest {
return dag.
Gotest().
WithUserAsOwnerOfDirs(user, dirs)
}
@function
def example(user: str, dirs: List[str]) -> dag.Gotest:
return (
dag.gotest()
.with_user_as_owner_of_dirs(user, dirs)
)
@func()
example(user: string, dirs: string[]): Gotest {
return dag
.gotest()
.withUserAsOwnerOfDirs(user, dirs)
}
withUserWithPermissionsOnDirs() 🔗
WithUserWithPermissionsOnDirs sets the specified permissions on the given directories within the container.
This method iterates over the provided list of directories and executes the “chmod” command within the container to change the permissions of each directory to the specified mode.
Parameters: - user: The user to set as the owner of the directories. This should be a valid user within the container. - mode: The permissions to set on the directories. This should be a valid mode string (e.g., “0777”). - dirs: A slice of strings representing the directories to set the permissions of. Each directory path should be specified relative to the container’s filesystem. - configureAsRoot: Whether to configure the directories as root, and then it’ll use the given mode.
Returns: - *Terragrunt: The updated Terragrunt instance with the permissions of the specified directories changed.
Return Type
Gotest !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
user | String ! | - | user is the user to set as the owner of the directories. |
mode | String ! | - | mode is the permissions to set on the directories. |
dirs | [String ! ] ! | - | dirs is the directories to set the permissions of. |
configureAsRoot | Boolean | - | configureAsRoot is whether to configure the directories as root, and then it'll use the given mode. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
with-user-with-permissions-on-dirs --user string --mode string --dirs string1 --dirs string2
func (m *myModule) example(user string, mode string, dirs []string) *Gotest {
return dag.
Gotest().
WithUserWithPermissionsOnDirs(user, mode, dirs)
}
@function
def example(user: str, mode: str, dirs: List[str]) -> dag.Gotest:
return (
dag.gotest()
.with_user_with_permissions_on_dirs(user, mode, dirs)
)
@func()
example(user: string, mode: string, dirs: string[]): Gotest {
return dag
.gotest()
.withUserWithPermissionsOnDirs(user, mode, dirs)
}
runTest() 🔗
RunTest executes the Go tests for the specified source code and packages. It allows for customization of the test execution through various options, including environment variables, secrets, and build/test flags.
Parameters: - source: The source code to test. - packages: A slice of strings representing the packages to test. - envVars: A slice of strings representing the environment variables to set. - secrets: A slice of pointers to dagger.Secret representing the secrets to set. - enableDefaultOptions: A boolean flag to enable default options for the test command. - race: A boolean flag to enable the race detector in the Go command. - msan: A boolean flag to enable memory sanitizer in the Go command. - asan: A boolean flag to enable address sanitizer in the Go command. - buildTags: A string specifying build constraints for the Go command. - ldflags: A string setting flags for the linker in the Go command. - gcflags: A string setting flags for the Go compiler. - asmflags: A string setting flags for the assembler in the Go command. - trimpath: A boolean flag to remove all file system paths from the compiled binary. - work: A boolean flag to enable the creation of a temporary work directory. - buildMode: A string specifying the build mode for the Go command. - compiler: A string specifying the compiler to use for building. - gccgoflags: A string setting flags for the gccgo compiler. - mod: A string specifying the module mode for the Go command. - benchmark: A string specifying the benchmark to run. - benchmem: A boolean flag to enable memory allocation statistics. - benchtime: A string specifying the duration for benchmarks. - blockprofile: A string specifying the file for block profiling. - cover: A boolean flag to enable coverage analysis. - coverprofile: A string specifying the file for coverage profile output. - cpuprofile: A string specifying the file for CPU profiling. - testCount: An integer specifying the number of test iterations. - failfast: A boolean flag to stop the test run on the first failure. - enableJSONOutput: A boolean flag to enable JSON output for test results. - list: A string specifying a regex to filter tests. - memprofile: A string specifying the file for memory profiling. - mutexprofile: A string specifying the file for mutex profiling. - parallel: An integer specifying the maximum number of tests to run in parallel. - run: A string specifying a regex to select tests to run. - short: A boolean flag to enable short test mode. - timeout: A string specifying the maximum time to run tests. - verbose: A boolean flag that sets the verbosity level in the Go command.
Returns: - A pointer to a dagger.Container representing the test execution container, and an error if the execution fails.
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
source | Directory ! | - | source is the source code to test. |
packages | [String ! ] | - | packages are the packages to test. |
envVars | [String ! ] | - | envVars are the environment variables to set. |
secrets | [Secret ! ] | - | secrets are the secrets to set. |
enableDefaultOptions | Boolean | - | enableDefaultOptions enables the default options for the test command. |
race | Boolean | - | Build Options race enables the race detector in the Go command. It's equivalent to the -race flag. |
msan | Boolean | - | msan enables memory sanitizer in the Go command. It's equivalent to the -msan flag. |
asan | Boolean | - | asan enables address sanitizer in the Go command. It's equivalent to the -asan flag. |
buildTags | String | - | buildTags specifies build constraints for the Go command. It's equivalent to the -tags flag. |
ldflags | String | - | ldflags sets flags for the linker in the Go command. It's equivalent to the -ldflags flag. |
gcflags | String | - | gcflags sets flags for the Go compiler. It's equivalent to the -gcflags flag. |
asmflags | String | - | asmflags sets flags for the assembler in the Go command. It's equivalent to the -asmflags flag. |
trimpath | Boolean | - | trimpath removes all file system paths from the compiled binary. It's equivalent to the -trimpath flag. |
work | Boolean | - | work enables the creation of a temporary work directory. It's equivalent to the -work flag. |
buildMode | String | - | buildMode specifies the build mode for the Go command. It's equivalent to the -buildmode flag. |
compiler | String | - | compiler specifies the compiler to use for building. It's equivalent to the -compiler flag. |
gccgoflags | String | - | gccgoflags sets flags for the gccgo compiler. It's equivalent to the -gccgoflags flag. |
mod | String | - | mod specifies the module mode for the Go command. It's equivalent to the -mod flag. |
benchmark | String | - | Test Options benchmark specifies the benchmark to run. It's equivalent to the -bench flag. |
benchmem | Boolean | - | benchmem enables memory allocation statistics. It's equivalent to the -benchmem flag. |
benchtime | String | - | benchtime specifies the duration for benchmarks. It's equivalent to the -benchtime flag. |
blockprofile | String | - | blockprofile specifies the file for block profiling. It's equivalent to the -blockprofile flag. |
cover | Boolean | - | cover enables coverage analysis. It's equivalent to the -cover flag. |
coverprofile | String | - | coverprofile specifies the file for coverage profile output. It's equivalent to the -coverprofile flag. |
cpuprofile | String | - | cpuprofile specifies the file for CPU profiling. It's equivalent to the -cpuprofile flag. |
testCount | Integer | - | testCount specifies the number of test iterations. It's equivalent to the -count flag. |
failfast | Boolean | - | failfast stops the test run on the first failure. It's equivalent to the -failfast flag. |
enableJsonoutput | Boolean | - | enableJSONOutput enables JSON output for test results. It's equivalent to the -json flag. |
list | String | - | list specifies a regex to filter tests. It's equivalent to the -list flag. |
memprofile | String | - | memprofile specifies the file for memory profiling. It's equivalent to the -memprofile flag. |
mutexprofile | String | - | mutexprofile specifies the file for mutex profiling. It's equivalent to the -mutexprofile flag. |
parallel | Integer | - | parallel specifies the maximum number of tests to run in parallel. It's equivalent to the -parallel flag. |
run | String | - | run specifies a regex to select tests to run. It's equivalent to the -run flag. |
short | Boolean | - | short enables short test mode. It's equivalent to the -short flag. |
timeout | String | - | timeout specifies the maximum time to run tests. It's equivalent to the -timeout flag. |
verbose | Boolean | - | verbose is the flag that sets the verbosity level in the Go command. It's equivalent to the -v flag. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
run-test --source DIR_PATH
func (m *myModule) example(source *Directory) *Container {
return dag.
Gotest().
RunTest(source)
}
@function
def example(source: dagger.Directory) -> dagger.Container:
return (
dag.gotest()
.run_test(source)
)
@func()
example(source: Directory): Container {
return dag
.gotest()
.runTest(source)
}
runTestCmd() 🔗
RunTestCmd executes the Go test command with the specified options and parameters.
This function allows for a comprehensive configuration of the test command, including build options, test options, and environment settings. It takes a context for managing cancellation and timeouts, a source directory for the code to be tested, and various flags to customize the behavior of the test execution. The function returns the output of the command as a string and any error encountered during execution.
Parameters: - ctx: The context to run the command. +optional - source: The source code to test. - packages: The packages to test. +optional - envVars: The environment variables to set. +optional - secrets: The secrets to set. +optional - enableDefaultOptions: Enables the default options for the test command. +optional - race: Enables the race detector in the Go command. It’s equivalent to the -race flag. +optional - msan: Enables memory sanitizer in the Go command. It’s equivalent to the -msan flag. +optional - asan: Enables address sanitizer in the Go command. It’s equivalent to the -asan flag. +optional - buildTags: Specifies build constraints for the Go command. It’s equivalent to the -tags flag. +optional - ldflags: Sets flags for the linker in the Go command. It’s equivalent to the -ldflags flag. +optional - gcflags: Sets flags for the Go compiler. It’s equivalent to the -gcflags flag. +optional - asmflags: Sets flags for the assembler in the Go command. It’s equivalent to the -asmflags flag. +optional - trimpath: Removes all file system paths from the compiled binary. It’s equivalent to the -trimpath flag. +optional - work: Enables the creation of a temporary work directory. It’s equivalent to the -work flag. +optional - buildMode: Specifies the build mode for the Go command. It’s equivalent to the -buildmode flag. +optional - compiler: Specifies the compiler to use for building. It’s equivalent to the -compiler flag. +optional - gccgoflags: Sets flags for the gccgo compiler. It’s equivalent to the -gccgoflags flag. +optional - mod: Specifies the module mode for the Go command. It’s equivalent to the -mod flag. +optional - benchmark: Specifies the benchmark to run. It’s equivalent to the -bench flag. +optional - benchmem: Enables memory allocation statistics. It’s equivalent to the -benchmem flag. +optional - benchtime: Specifies the duration for benchmarks. It’s equivalent to the -benchtime flag. +optional - blockprofile: Specifies the file for block profiling. It’s equivalent to the -blockprofile flag. +optional - cover: Enables coverage analysis. It’s equivalent to the -cover flag. +optional - coverprofile: Specifies the file for coverage profile output. It’s equivalent to the -coverprofile flag. +optional - cpuprofile: Specifies the file for CPU profiling. It’s equivalent to the -cpuprofile flag. +optional - testCount: Specifies the number of test iterations. It’s equivalent to the -count flag. +optional - failfast: Stops the test run on the first failure. It’s equivalent to the -failfast flag. +optional - enableJsonOutput: Enables JSON output for test results. It’s equivalent to the -json flag. +optional - list: Specifies a regex to filter tests. It’s equivalent to the -list flag. +optional - memprofile: Specifies the file for memory profiling. It’s equivalent to the -memprofile flag. +optional - mutexprofile: Specifies the file for mutex profiling. It’s equivalent to the -mutexprofile flag. +optional - parallel: Specifies the maximum number of tests to run in parallel. It’s equivalent to the -parallel flag. +optional - run: Specifies a regex to select tests to run. It’s equivalent to the -run flag. +optional - short: Enables short test mode. It’s equivalent to the -short flag. +optional - timeout: Specifies the maximum time to run tests. It’s equivalent to the -timeout flag. +optional - verbose: Is the flag that sets the verbosity level in the Go command. It’s equivalent to the -v flag. +optional
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
source | Directory ! | - | source is the source code to test. |
packages | [String ! ] | - | packages are the packages to test. |
envVars | [String ! ] | - | envVars are the environment variables to set. |
secrets | [Secret ! ] | - | secrets are the secrets to set. |
enableDefaultOptions | Boolean | - | enableDefaultOptions enables the default options for the test command. |
race | Boolean | - | Build Options race enables the race detector in the Go command. It's equivalent to the -race flag. |
msan | Boolean | - | msan enables memory sanitizer in the Go command. It's equivalent to the -msan flag. |
asan | Boolean | - | asan enables address sanitizer in the Go command. It's equivalent to the -asan flag. |
buildTags | String | - | buildTags specifies build constraints for the Go command. It's equivalent to the -tags flag. |
ldflags | String | - | ldflags sets flags for the linker in the Go command. It's equivalent to the -ldflags flag. |
gcflags | String | - | gcflags sets flags for the Go compiler. It's equivalent to the -gcflags flag. |
asmflags | String | - | asmflags sets flags for the assembler in the Go command. It's equivalent to the -asmflags flag. |
trimpath | Boolean | - | trimpath removes all file system paths from the compiled binary. It's equivalent to the -trimpath flag. |
work | Boolean | - | work enables the creation of a temporary work directory. It's equivalent to the -work flag. |
buildMode | String | - | buildMode specifies the build mode for the Go command. It's equivalent to the -buildmode flag. |
compiler | String | - | compiler specifies the compiler to use for building. It's equivalent to the -compiler flag. |
gccgoflags | String | - | gccgoflags sets flags for the gccgo compiler. It's equivalent to the -gccgoflags flag. |
mod | String | - | mod specifies the module mode for the Go command. It's equivalent to the -mod flag. |
benchmark | String | - | Test Options benchmark specifies the benchmark to run. It's equivalent to the -bench flag. |
benchmem | Boolean | - | benchmem enables memory allocation statistics. It's equivalent to the -benchmem flag. |
benchtime | String | - | benchtime specifies the duration for benchmarks. It's equivalent to the -benchtime flag. |
blockprofile | String | - | blockprofile specifies the file for block profiling. It's equivalent to the -blockprofile flag. |
cover | Boolean | - | cover enables coverage analysis. It's equivalent to the -cover flag. |
coverprofile | String | - | coverprofile specifies the file for coverage profile output. It's equivalent to the -coverprofile flag. |
cpuprofile | String | - | cpuprofile specifies the file for CPU profiling. It's equivalent to the -cpuprofile flag. |
testCount | Integer | - | testCount specifies the number of test iterations. It's equivalent to the -count flag. |
failfast | Boolean | - | failfast stops the test run on the first failure. It's equivalent to the -failfast flag. |
enableJsonoutput | Boolean | - | enableJSONOutput enables JSON output for test results. It's equivalent to the -json flag. |
list | String | - | list specifies a regex to filter tests. It's equivalent to the -list flag. |
memprofile | String | - | memprofile specifies the file for memory profiling. It's equivalent to the -memprofile flag. |
mutexprofile | String | - | mutexprofile specifies the file for mutex profiling. It's equivalent to the -mutexprofile flag. |
parallel | Integer | - | parallel specifies the maximum number of tests to run in parallel. It's equivalent to the -parallel flag. |
run | String | - | run specifies a regex to select tests to run. It's equivalent to the -run flag. |
short | Boolean | - | short enables short test mode. It's equivalent to the -short flag. |
timeout | String | - | timeout specifies the maximum time to run tests. It's equivalent to the -timeout flag. |
verbose | Boolean | - | verbose is the flag that sets the verbosity level in the Go command. It's equivalent to the -v flag. |
Example
dagger -m github.com/Excoriate/daggerverse/gotest@061077d98cbe425ee92c83ad218df464c9677e75 call \
run-test-cmd --source DIR_PATH
func (m *myModule) example(ctx context.Context, source *Directory) string {
return dag.
Gotest().
RunTestCmd(ctx, source)
}
@function
async def example(source: dagger.Directory) -> str:
return await (
dag.gotest()
.run_test_cmd(source)
)
@func()
async example(source: Directory): Promise<string> {
return dag
.gotest()
.runTestCmd(source)
}