### Example: Run a Specific Backend Test Source: https://github.com/fastly/cli/blob/main/TESTING.md This example demonstrates how to run a specific test for backend commands, targeting `TestBackendCreate` within the `./pkg/commands/backend` directory. ```sh make test TEST_ARGS="-run TestBackendCreate ./pkg/commands/backend" ``` -------------------------------- ### Install Build Dependencies Source: https://github.com/fastly/cli/blob/main/DEVELOPMENT.md Run 'make mod-download' to automatically install or upgrade required executables like golint, gosec, and staticcheck if they are not found in your PATH. ```sh make mod-download ``` -------------------------------- ### Install and Inspect Platform-Specific npm Package Source: https://github.com/fastly/cli/blob/main/RELEASE.md Install a specific platform/architecture npm package for the Fastly CLI and list its contents. This demonstrates the structure of the installed package, including the binary and shim. ```shell npm install @fastly/cli-darwin-arm64 --verbose ls node_modules/@fastly/cli-darwin-arm64 ``` -------------------------------- ### Build and Test Fastly CLI Source: https://github.com/fastly/cli/blob/main/DEVELOPMENT.md Clone the repository and run 'make' to execute all tests and generate a local development build. Ensure Go (1.18+) and Rust are installed. ```sh git clone git@github.com:fastly/cli cd cli make ./fastly version ``` -------------------------------- ### Enable Integration Tests with Environment Variables Source: https://github.com/fastly/cli/blob/main/TESTING.md Certain integration tests require specific environment variables to be set. For example, setting `TEST_COMPUTE_BUILD_RUST=1` enables Rust build tests. ```sh TEST_COMPUTE_BUILD_RUST=1 make test TEST_ARGS="-run TestBuildRust/fastly_crate_prerelease ./pkg/compute/..." ``` -------------------------------- ### Run the Test Suite Source: https://github.com/fastly/cli/blob/main/TESTING.md Execute the entire test suite using the make command. By default, it uses `go test` with race detection enabled. ```sh make test ``` -------------------------------- ### Run Full Test Suite with Compute Features Source: https://github.com/fastly/cli/blob/main/TESTING.md To execute the full test suite including compute initialization, build, and deployment tests, set the corresponding environment variables and use `make all`. ```sh TEST_COMPUTE_INIT=1 TEST_COMPUTE_BUILD=1 TEST_COMPUTE_DEPLOY=1 TEST_COMMAND=gotest make all ``` -------------------------------- ### Build Local Release Candidate Source: https://github.com/fastly/cli/blob/main/RELEASE.md Build a local snapshot release using goreleaser, skipping validation and post-hooks. This is useful for testing the release build process without a full release. ```shell make release GORELEASER_ARGS="--snapshot --skip=validate --skip=post-hooks --clean" ``` -------------------------------- ### Run Compute Commands Locally with --dir Flag Source: https://github.com/fastly/cli/blob/main/DEVELOPMENT.md Use the --dir flag with Fastly CLI Compute commands like `deploy` to prevent the CLI from treating the repository directory as the project directory during local testing. ```shell go run cmd/fastly/main.go compute deploy --verbose --dir ../../test-projects/testing-fastly-cli ``` -------------------------------- ### Run Specific Tests Source: https://github.com/fastly/cli/blob/main/TESTING.md To run a specific test, use the `TEST_ARGS` variable with the `-run` flag and the path to the test directory. Replace `<...>` with the test name and `` with the directory. ```sh make test TEST_ARGS="-run <...> " ``` -------------------------------- ### Run All Analysis Checks and Tests Source: https://github.com/fastly/cli/blob/main/RELEASE.md Execute all analysis checks and tests for the project. This command ensures the codebase is stable and meets quality standards before proceeding with a release. ```shell time TEST_COMPUTE_INIT=1 TEST_COMPUTE_BUILD=1 TEST_COMPUTE_DEPLOY=1 make all ``` -------------------------------- ### Create and Push Signed Git Tag Source: https://github.com/fastly/cli/blob/main/RELEASE.md Create a new signed Git tag for the release and push it to the remote repository. This action triggers a GitHub Action to create a draft release. ```shell tag=vX.Y.Z && git tag -s $tag -m $tag && git push {{remote}} $tag ``` -------------------------------- ### Scaffold New Top-Level API Command Source: https://github.com/fastly/cli/blob/main/DEVELOPMENT.md Use 'make scaffold' with environment variables to generate a new non-composite command. The CLI_API value is interpolated into CRUD verbs and input types. ```sh CLI_PACKAGE=foobar CLI_COMMAND=foo-bar CLI_API=Bar make scaffold ``` -------------------------------- ### Add Upstream Remote Source: https://github.com/fastly/cli/blob/main/CONTRIBUTING.md Add the upstream remote repository to your local clone. This is necessary for fetching the latest changes from the main project. ```bash git remote add upstream git@github.com:fastly/cli.git ``` -------------------------------- ### Scaffold New Command in Existing Category Source: https://github.com/fastly/cli/blob/main/DEVELOPMENT.md Use 'make scaffold-category' with additional environment variables to add a new subcommand to an existing category. Manually update any '<...>' references in generated files. ```sh CLI_CATEGORY=logging CLI_CATEGORY_COMMAND=logging CLI_PACKAGE=foobar CLI_COMMAND=foo-bar CLI_API=Bar make scaffold-category ``` -------------------------------- ### Debug Failing Tests with Delve Source: https://github.com/fastly/cli/blob/main/TESTING.md To debug failing tests, navigate to the package directory containing the test file and use Delve with the `dlv test` command. The `-test.v` and `-test.run` flags are used to specify verbose output and the test to run. ```sh TEST_COMPUTE_BUILD=1 dlv test -- -test.v -test.run TestNameGoesHere ``` -------------------------------- ### Makefile Target Structure for Scaffolding Source: https://github.com/fastly/cli/blob/main/DEVELOPMENT.md Defines the structure for Makefile targets used in scaffolding new commands, differentiating between top-level commands and those within categories. ```bash CLI_PACKAGE=... CLI_COMMAND=... CLI_API=... make scaffold CLI_CATEGORY=... CLI_CATEGORY_COMMAND=... CLI_PACKAGE=... CLI_COMMAND=... CLI_API=... make scaffold-category ``` -------------------------------- ### Set Breakpoint in Delve Source: https://github.com/fastly/cli/blob/main/TESTING.md Once Delve is running, you can set breakpoints using the `break` command followed by the file path and line number. The path is relative to the package directory where the test is being run. ```sh break ../../app/run.go:152 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.