summaryrefslogtreecommitdiff
path: root/vendor/github.com/hashicorp/terraform/vendor/github.com/hashicorp/consul/testutil/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/vendor/github.com/hashicorp/consul/testutil/README.md')
-rw-r--r--vendor/github.com/hashicorp/terraform/vendor/github.com/hashicorp/consul/testutil/README.md31
1 files changed, 22 insertions, 9 deletions
diff --git a/vendor/github.com/hashicorp/terraform/vendor/github.com/hashicorp/consul/testutil/README.md b/vendor/github.com/hashicorp/terraform/vendor/github.com/hashicorp/consul/testutil/README.md
index 21eb01d2..bd84f822 100644
--- a/vendor/github.com/hashicorp/terraform/vendor/github.com/hashicorp/consul/testutil/README.md
+++ b/vendor/github.com/hashicorp/terraform/vendor/github.com/hashicorp/consul/testutil/README.md
@@ -25,41 +25,54 @@ import (
"github.com/hashicorp/consul/testutil"
)
-func TestMain(t *testing.T) {
+func TestFoo_bar(t *testing.T) {
// Create a test Consul server
- srv1 := testutil.NewTestServer(t)
+ srv1, err := testutil.NewTestServer()
+ if err != nil {
+ t.Fatal(err)
+ }
defer srv1.Stop()
// Create a secondary server, passing in configuration
// to avoid bootstrapping as we are forming a cluster.
- srv2 := testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
+ srv2, err := testutil.NewTestServerConfig(t, func(c *testutil.TestServerConfig) {
c.Bootstrap = false
})
+ if err != nil {
+ t.Fatal(err)
+ }
defer srv2.Stop()
// Join the servers together
- srv1.JoinLAN(srv2.LANAddr)
+ srv1.JoinLAN(t, srv2.LANAddr)
// Create a test key/value pair
- srv1.SetKV("foo", []byte("bar"))
+ srv1.SetKV(t, "foo", []byte("bar"))
// Create lots of test key/value pairs
- srv1.PopulateKV(map[string][]byte{
+ srv1.PopulateKV(t, map[string][]byte{
"bar": []byte("123"),
"baz": []byte("456"),
})
// Create a service
- srv1.AddService("redis", structs.HealthPassing, []string{"master"})
+ srv1.AddService(t, "redis", structs.HealthPassing, []string{"master"})
+
+ // Create a service that will be accessed in target source code
+ srv1.AddAccessibleService("redis", structs.HealthPassing, "127.0.0.1", 6379, []string{"master"})
// Create a service check
- srv1.AddCheck("service:redis", "redis", structs.HealthPassing)
+ srv1.AddCheck(t, "service:redis", "redis", structs.HealthPassing)
// Create a node check
- srv1.AddCheck("mem", "", structs.HealthCritical)
+ srv1.AddCheck(t, "mem", "", structs.HealthCritical)
// The HTTPAddr field contains the address of the Consul
// API on the new test server instance.
println(srv1.HTTPAddr)
+
+ // All functions also have a wrapper method to limit the passing of "t"
+ wrap := srv1.Wrap(t)
+ wrap.SetKV("foo", []byte("bar"))
}
```