github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/e2eutil/client.go (about) 1 package e2eutil 2 3 import ( 4 "testing" 5 6 capi "github.com/hashicorp/consul/api" 7 napi "github.com/hashicorp/nomad/api" 8 vapi "github.com/hashicorp/vault/api" 9 10 "github.com/stretchr/testify/require" 11 ) 12 13 // NomadClient creates a default Nomad client based on the env vars 14 // from the test environment. Fails the test if it can't be created 15 func NomadClient(t *testing.T) *napi.Client { 16 client, err := napi.NewClient(napi.DefaultConfig()) 17 require.NoError(t, err, "could not create Nomad client") 18 return client 19 } 20 21 // ConsulClient creates a default Consul client based on the env vars 22 // from the test environment. Fails the test if it can't be created 23 func ConsulClient(t *testing.T) *capi.Client { 24 client, err := capi.NewClient(capi.DefaultConfig()) 25 require.NoError(t, err, "could not create Consul client") 26 return client 27 } 28 29 // VaultClient creates a default Vault client based on the env vars 30 // from the test environment. Fails the test if it can't be created 31 func VaultClient(t *testing.T) *vapi.Client { 32 client, err := vapi.NewClient(vapi.DefaultConfig()) 33 require.NoError(t, err, "could not create Vault client") 34 return client 35 }