How do I run tests for the project?
You can run tests for the project using the go test
command.
Running Tests
Navigate to the project directory
cd github.com/daytonaio/daytona
Run the tests
go test ./...
This command will run all tests in the project.
You can run tests for specific packages by replacing
./...
with the package path. For example, to run tests in thepkg/agent
package:go test ./pkg/agent/...
To run tests for a specific file, replace
./...
with the file path. For example, to run tests inpkg/agent/agent_test.go
:go test ./pkg/agent/agent_test.go
Running Tests with Build Constraints
Some files in the project have a build constraint defined as “testing”. This means that these files will only be compiled when running tests. You can run tests with this constraint using the -tags=testing
flag. For example, to run tests for the pkg/build
package with the “testing” build constraint:
go test -tags=testing ./pkg/build/...
Example: Running Tests in pkg/build
The following code snippet shows how to run tests in the pkg/build
package:
go test -tags=testing ./pkg/build/...
Note: This command will run all tests in the pkg/build
package that have the “testing” build constraint.
Example: Running Tests in pkg/agent/agent_test.go
The following code snippet shows how to run tests in pkg/agent/agent_test.go
go test -tags=testing ./pkg/agent/agent_test.go
This will run the tests in pkg/agent/agent_test.go
with the “testing” build constraint.
Example: Running Tests in pkg/build/builder_test.go
The following code snippet shows how to run tests in pkg/build/builder_test.go
go test -tags=testing ./pkg/build/builder_test.go
This will run the tests in pkg/build/builder_test.go
with the “testing” build constraint.