From 7f14d3ac8a5a91617e765ff4ffc0e8ab2ef7ba97 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 d98a02f40..dbdd37590 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 0ef7c0c47..3a0ed36ec 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 {