From dfcf45c6cf82716a34a457d101b1d611b5641e3c Mon Sep 17 00:00:00 2001 From: Hans Hasselberg Date: Thu, 4 Jun 2020 22:59:06 +0200 Subject: [PATCH] tests: use constructor instead init (#8024) --- agent/agent_test.go | 8 +++----- agent/checks/alias.go | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/agent/agent_test.go b/agent/agent_test.go index d98a02f406..dbdd37590f 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -651,9 +651,8 @@ func test_createAlias(t *testing.T, agent *TestAgent, chk *structs.CheckType, ex if c.Check.CheckID == chk.CheckID { found = true assert.Equal(t, expectedResult, c.Check.Status, "Check state should be %s, was %s in %#v", expectedResult, c.Check.Status, c.Check) - var srvID structs.ServiceID - srvID.Init(srv.ID, structs.WildcardEnterpriseMeta()) - if err := agent.Agent.State.RemoveService(structs.ServiceID(srvID)); err != nil { + srvID := structs.NewServiceID(srv.ID, structs.WildcardEnterpriseMeta()) + if err := agent.Agent.State.RemoveService(srvID); err != nil { fmt.Println("[DEBUG] Fail to remove service", srvID, ", err:=", err) } fmt.Println("[DEBUG] Service Removed", srvID, ", err:=", err) @@ -714,8 +713,7 @@ func TestAgent_CheckAliasRPC(t *testing.T) { err := a.RPC("Catalog.NodeServices", &args, &out) assert.NoError(r, err) foundService := false - var lookup structs.ServiceID - lookup.Init("svcid1", structs.WildcardEnterpriseMeta()) + lookup := structs.NewServiceID("svcid1", structs.WildcardEnterpriseMeta()) for _, srv := range out.NodeServices.Services { sid := srv.CompoundServiceID() if lookup.Matches(&sid) { diff --git a/agent/checks/alias.go b/agent/checks/alias.go index 0ef7c0c479..3a0ed36eca 100644 --- a/agent/checks/alias.go +++ b/agent/checks/alias.go @@ -144,7 +144,7 @@ func (c *CheckAlias) checkServiceExistsOnRemoteServer(serviceID *structs.Service args.AllowStale = true args.EnterpriseMeta = c.EnterpriseMeta // We are late at maximum of 15s compared to leader - args.MaxStaleDuration = time.Duration(15 * time.Second) + args.MaxStaleDuration = 15 * time.Second attempts := 0 RETRY_CALL: var out structs.IndexedNodeServices @@ -172,7 +172,7 @@ func (c *CheckAlias) runQuery(stopCh chan struct{}) { args.MaxQueryTime = 1 * time.Minute args.EnterpriseMeta = c.EnterpriseMeta // We are late at maximum of 15s compared to leader - args.MaxStaleDuration = time.Duration(15 * time.Second) + args.MaxStaleDuration = 15 * time.Second var attempt uint for {