Skip to content

Latest commit

 

History

History
74 lines (51 loc) · 2.64 KB

README.md

File metadata and controls

74 lines (51 loc) · 2.64 KB

End-to-end tests

fnox uses Bats for end-to-end CLI tests. Run commands from the repository root with the project tools available through mise.

Build and run

mise install
mise run build
mise run test:bats

test:bats uses an existing binary. Rebuild after Rust changes so the tests exercise your changes.

For a focused run:

mise run test:bats -- test/version.bats

In an activated mise shell, invoke Bats directly for a name filter or timing:

bats test/version.bats --filter "fnox --version prints version"
bats test/version.bats --timing

The mise task resolves configured test credentials through fnox exec and runs Bats in parallel. Direct Bats invocations use the environment you supply.

Provider prerequisites

Provider tests skip when required credentials or services are unavailable. A skipped provider test does not validate that integration.

  • Bitwarden with Vaultwarden: local Docker service and an unlocked BW_SESSION.
  • HashiCorp Vault: local dev server and a test token.
  • 1Password: OP_SERVICE_ACCOUNT_TOKEN with access to the test vault.
  • Infisical: INFISICAL_TOKEN or the credentials required by the test setup.
  • KeePass: tests create temporary databases and use test passwords.
  • Passwordstate: PASSWORDSTATE_BASE_URL, PASSWORDSTATE_API_KEY, and PASSWORDSTATE_LIST_ID.

See the individual .bats file for the exact setup and skip conditions before running a provider test.

Write a test

Use the shared setup and teardown so config and temporary files are isolated:

setup() {
  load 'test_helper/common_setup'
  _common_setup
}

teardown() {
  _common_teardown
}

@test "fnox --version prints a version" {
  run fnox --version
  assert_success
  assert_output --regexp '^fnox [0-9]+\.[0-9]+\.[0-9]+'
}

Pass --git to _common_setup only when the test needs a repository. Follow adjacent tests for the behavior being exercised.

The shared setup selects target/debug/fnox when available, sets $FNOX_BIN, creates an isolated config environment, and puts test artifacts under tmp/. Teardown removes those artifacts unless Bats preservation options are enabled.

Helpers and fixtures

  • Assertions: config, secret, and command assertions.
  • Common setup: environment isolation and binary selection.
  • Fixtures: disposable provider data and certificates.

Keep fixtures free of real credentials. Test failures should show enough context to identify the first substantive error without dumping resolved secrets.