Skip to content

Commit

Permalink
test: skip tests if vault binary is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Oct 16, 2023
1 parent 37ec3cf commit 717d531
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions testutil/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ type TestVault struct {
}

func NewTestVaultFromPath(t testing.T, binary string) *TestVault {
t.Helper()

if _, err := exec.LookPath(binary); err != nil {
t.Skipf("Skipping test %s, Vault binary %q not found in path.", t.Name(), binary)
}

port := ci.PortAllocator.Grab(1)[0]
token := uuid.Generate()
bind := fmt.Sprintf("-dev-listen-address=127.0.0.1:%d", port)
Expand Down Expand Up @@ -112,6 +118,8 @@ func NewTestVaultFromPath(t testing.T, binary string) *TestVault {

// NewTestVault returns a new TestVault instance that is ready for API calls
func NewTestVault(t testing.T) *TestVault {
t.Helper()

// Lookup vault from the path
return NewTestVaultFromPath(t, "vault")
}
Expand Down

0 comments on commit 717d531

Please sign in to comment.