From f300d7bc65911530730692529e45e2c76fb2965f Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Thu, 31 May 2018 17:20:16 -0400 Subject: [PATCH] Update unit tests to reflect change to func signature --- agent/agent_test.go | 20 ++++++++++++++++++++ watch/funcs_test.go | 18 +++++++++--------- watch/plan_test.go | 2 +- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/agent/agent_test.go b/agent/agent_test.go index b4989de66..58ada5561 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -2206,3 +2206,23 @@ func TestAgent_reloadWatches(t *testing.T) { t.Fatalf("bad: %s", err) } } + +func TestAgent_reloadWatchesHTTPS(t *testing.T) { + t.Parallel() + a := TestAgent{Name: t.Name(), UseTLS: true} + a.Start() + defer a.Shutdown() + + // Normal watch with http addr set, should succeed + newConf := *a.config + newConf.Watches = []map[string]interface{}{ + { + "type": "key", + "key": "asdf", + "args": []interface{}{"ls"}, + }, + } + if err := a.reloadWatches(&newConf); err != nil { + t.Fatalf("bad: %s", err) + } +} diff --git a/watch/funcs_test.go b/watch/funcs_test.go index 190ae24fa..35de2387a 100644 --- a/watch/funcs_test.go +++ b/watch/funcs_test.go @@ -64,7 +64,7 @@ func TestKeyWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr()); err != nil { + if err := plan.Run(a.HTTPAddr(), nil); err != nil { t.Fatalf("err: %v", err) } }() @@ -118,7 +118,7 @@ func TestKeyWatch_With_PrefixDelete(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr()); err != nil { + if err := plan.Run(a.HTTPAddr(), nil); err != nil { t.Fatalf("err: %v", err) } }() @@ -171,7 +171,7 @@ func TestKeyPrefixWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr()); err != nil { + if err := plan.Run(a.HTTPAddr(), nil); err != nil { t.Fatalf("err: %v", err) } }() @@ -225,7 +225,7 @@ func TestServicesWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr()); err != nil { + if err := plan.Run(a.HTTPAddr(), nil); err != nil { t.Fatalf("err: %v", err) } }() @@ -276,7 +276,7 @@ func TestNodesWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr()); err != nil { + if err := plan.Run(a.HTTPAddr(), nil); err != nil { t.Fatalf("err: %v", err) } }() @@ -332,7 +332,7 @@ func TestServiceWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr()); err != nil { + if err := plan.Run(a.HTTPAddr(), nil); err != nil { t.Fatalf("err: %v", err) } }() @@ -393,7 +393,7 @@ func TestChecksWatch_State(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr()); err != nil { + if err := plan.Run(a.HTTPAddr(), nil); err != nil { t.Fatalf("err: %v", err) } }() @@ -459,7 +459,7 @@ func TestChecksWatch_Service(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr()); err != nil { + if err := plan.Run(a.HTTPAddr(), nil); err != nil { t.Fatalf("err: %v", err) } }() @@ -510,7 +510,7 @@ func TestEventWatch(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - if err := plan.Run(a.HTTPAddr()); err != nil { + if err := plan.Run(a.HTTPAddr(), nil); err != nil { t.Fatalf("err: %v", err) } }() diff --git a/watch/plan_test.go b/watch/plan_test.go index 16e4cfbc2..c7b16fade 100644 --- a/watch/plan_test.go +++ b/watch/plan_test.go @@ -47,7 +47,7 @@ func TestRun_Stop(t *testing.T) { errCh := make(chan error, 1) go func() { - errCh <- plan.Run("127.0.0.1:8500") + errCh <- plan.Run("127.0.0.1:8500", nil) }() select {