git clone git@github.com:fastly/cli.git
cd cli
go install github.com/go-delve/delve/cmd/dlv@latest
(install the debugger)dlv debug ./cmd/fastly/main.go -- compute deploy
(start up the debugger)break ./pkg/commands/compute/deploy.go:89
(add break point within the 'deploy' code file)cond <breakpoint_name_or_id> <boolean expression>
(e.g.cond 1 commandName == "sso"
)continue
(this would be typed into the debugger prompt and would cause the code to run until the breakpoint)
From there you can use n
(next) to go from line-to-line or s
(step-into) to jump into any function calls, along with print
to see what the code is doing.
To exercise the test code:
dlv test ./pkg/example/... -- -test.v -test.run TestExample/specific_test_case
break ./pkg/example/example_test.go:123
NOTE: If you see the error "cannot use -c flag with multiple packages" then
cd
into the package directory (e.g.cd ./pkg/example && dlv test
).
Fastly Terraform Tests:
cd ./fastly
TF_ACC=true dlv test -- -test.v -test.run TestAccFastlyServiceVCL_syslog_useTLS
break block_fastly_service_logging_syslog_test.go:253 // break inside the test code
break block_fastly_service_logging_syslog.go:342 // break inside the execute terraform code (trigged by the test)
Fastly CLI Tests:
cd ./pkg/commands/compute
TEST_COMPUTE_BUILD=1 dlv test -- -test.v -test.run TestBuildAssemblyScript/successful_build
break build_test.go:328