Skip to content

Development

Building

make build              # bin/clickvault, current OS/arch
make build-linux-amd64  # bin/clickvault-linux-amd64
make build-linux-arm64  # bin/clickvault-linux-arm64
make sha256             # builds linux/amd64 and prints its sha256sum

Testing

Unit tests

Unit tests mock the database connection using go-sqlmock and do not need Docker or a running ClickHouse:

make test
# or
go test ./...

Integration tests

Integration tests spin up a real ClickHouse container (matching testdata/docker-compose.yml) with the Vault SDK's Docker test helper, and drive the full lifecycle:

  1. Initialize - configure the connection
  2. NewUser - create a dynamic user
  3. Verify the user can connect to ClickHouse
  4. DeleteUser - revoke the user
  5. Verify the user can no longer connect
  6. Repeat DeleteUser to confirm idempotency
  7. UpdateUser on a static-style user with before/after connection checks

Integration tests are gated behind the integration build tag:

go test -tags=integration ./tests/...

Docker must be running locally for that command to work.

Repository layout

clickvault/
├── go.mod, go.sum                    module github.com/emiliano-go/clickvault
├── main.go                           plugin entrypoint
├── internal/clickvault/
│   ├── clickvault.go                  ClickvaultPlugin and six dbplugin methods
│   ├── clickvault_test.go             unit tests (go-sqlmock)
│   ├── ddl.go                         all SQL construction and cluster branching
│   └── ddl_test.go                    table-driven tests for ddl.go
├── testdata/docker-compose.yml        single-node ClickHouse for manual testing
├── tests/integration_test.go          integration tests against real ClickHouse
├── scripts/setup_vault.sh             registers and configures the plugin
└── .github/workflows/ci.yml           go vet, go test, build, sha256 artifact