From ceda18366fefcf22bb8f84cd13fa9247ee99cca8 Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Wed, 31 May 2017 09:21:01 +0200 Subject: [PATCH] test: Use Bool() instead of &BoolTrue/False since --- command/agent/acl_test.go | 28 ++++++++++++++-------------- command/agent/dns_test.go | 8 ++++---- command/agent/local_test.go | 4 ++-- command/agent/testagent.go | 6 +----- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/command/agent/acl_test.go b/command/agent/acl_test.go index a3be7f783b..fa2fe016c4 100644 --- a/command/agent/acl_test.go +++ b/command/agent/acl_test.go @@ -40,7 +40,7 @@ func (m *MockServer) GetPolicy(args *structs.ACLPolicyRequest, reply *structs.AC func TestACL_Version8(t *testing.T) { t.Parallel() cfg := TestConfig() - cfg.ACLEnforceVersion8 = &BoolFalse + cfg.ACLEnforceVersion8 = Bool(false) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -63,7 +63,7 @@ func TestACL_Disabled(t *testing.T) { t.Parallel() cfg := TestACLConfig() cfg.ACLDisabledTTL = 10 * time.Millisecond - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -115,7 +115,7 @@ func TestACL_Disabled(t *testing.T) { func TestACL_Special_IDs(t *testing.T) { t.Parallel() cfg := TestACLConfig() - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) cfg.ACLAgentMasterToken = "towel" a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -168,7 +168,7 @@ func TestACL_Down_Deny(t *testing.T) { t.Parallel() cfg := TestACLConfig() cfg.ACLDownPolicy = "deny" - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -198,7 +198,7 @@ func TestACL_Down_Allow(t *testing.T) { t.Parallel() cfg := TestACLConfig() cfg.ACLDownPolicy = "allow" - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -228,7 +228,7 @@ func TestACL_Down_Extend(t *testing.T) { t.Parallel() cfg := TestACLConfig() cfg.ACLDownPolicy = "extend-cache" - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -305,7 +305,7 @@ func TestACL_Down_Extend(t *testing.T) { func TestACL_Cache(t *testing.T) { t.Parallel() cfg := TestACLConfig() - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -487,7 +487,7 @@ func catalogPolicy(req *structs.ACLPolicyRequest, reply *structs.ACLPolicy) erro func TestACL_vetServiceRegister(t *testing.T) { t.Parallel() cfg := TestACLConfig() - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -533,7 +533,7 @@ func TestACL_vetServiceRegister(t *testing.T) { func TestACL_vetServiceUpdate(t *testing.T) { t.Parallel() cfg := TestACLConfig() - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -569,7 +569,7 @@ func TestACL_vetServiceUpdate(t *testing.T) { func TestACL_vetCheckRegister(t *testing.T) { t.Parallel() cfg := TestACLConfig() - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -652,7 +652,7 @@ func TestACL_vetCheckRegister(t *testing.T) { func TestACL_vetCheckUpdate(t *testing.T) { t.Parallel() cfg := TestACLConfig() - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -708,7 +708,7 @@ func TestACL_vetCheckUpdate(t *testing.T) { func TestACL_filterMembers(t *testing.T) { t.Parallel() cfg := TestACLConfig() - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -744,7 +744,7 @@ func TestACL_filterMembers(t *testing.T) { func TestACL_filterServices(t *testing.T) { t.Parallel() cfg := TestACLConfig() - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -775,7 +775,7 @@ func TestACL_filterServices(t *testing.T) { func TestACL_filterChecks(t *testing.T) { t.Parallel() cfg := TestACLConfig() - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() diff --git a/command/agent/dns_test.go b/command/agent/dns_test.go index 5697dbf279..31ccf3333c 100644 --- a/command/agent/dns_test.go +++ b/command/agent/dns_test.go @@ -2863,7 +2863,7 @@ func TestDNS_NodeLookup_TTL(t *testing.T) { cfg := TestConfig() cfg.DNSRecursor = recursor.Addr cfg.DNSConfig.NodeTTL = 10 * time.Second - cfg.DNSConfig.AllowStale = &BoolTrue + cfg.DNSConfig.AllowStale = Bool(true) cfg.DNSConfig.MaxStale = time.Second a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -2981,7 +2981,7 @@ func TestDNS_ServiceLookup_TTL(t *testing.T) { "db": 10 * time.Second, "*": 5 * time.Second, } - cfg.DNSConfig.AllowStale = &BoolTrue + cfg.DNSConfig.AllowStale = Bool(true) cfg.DNSConfig.MaxStale = time.Second a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -3081,7 +3081,7 @@ func TestDNS_PreparedQuery_TTL(t *testing.T) { "db": 10 * time.Second, "*": 5 * time.Second, } - cfg.DNSConfig.AllowStale = &BoolTrue + cfg.DNSConfig.AllowStale = Bool(true) cfg.DNSConfig.MaxStale = time.Second a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() @@ -3825,7 +3825,7 @@ func TestDNS_NonExistingLookupEmptyAorAAAA(t *testing.T) { func TestDNS_PreparedQuery_AllowStale(t *testing.T) { t.Parallel() cfg := TestConfig() - cfg.DNSConfig.AllowStale = &BoolTrue + cfg.DNSConfig.AllowStale = Bool(true) cfg.DNSConfig.MaxStale = time.Second a := NewTestAgent(t.Name(), cfg) defer a.Shutdown() diff --git a/command/agent/local_test.go b/command/agent/local_test.go index ac3615d0f7..27e121888e 100644 --- a/command/agent/local_test.go +++ b/command/agent/local_test.go @@ -470,7 +470,7 @@ func TestAgentAntiEntropy_Services_ACLDeny(t *testing.T) { cfg.ACLDatacenter = "dc1" cfg.ACLMasterToken = "root" cfg.ACLDefaultPolicy = "deny" - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := &TestAgent{Name: t.Name(), Config: cfg, NoInitialSync: true} a.Start() defer a.Shutdown() @@ -842,7 +842,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) { cfg.ACLDatacenter = "dc1" cfg.ACLMasterToken = "root" cfg.ACLDefaultPolicy = "deny" - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) a := &TestAgent{Name: t.Name(), Config: cfg, NoInitialSync: true} a.Start() defer a.Shutdown() diff --git a/command/agent/testagent.go b/command/agent/testagent.go index 11793c00d9..8b483494b5 100644 --- a/command/agent/testagent.go +++ b/command/agent/testagent.go @@ -279,10 +279,6 @@ func pickRandomPorts(c *Config) { c.Ports.Server = port + 6 } -// BoolTrue and BoolFalse exist to create a *bool value. -var BoolTrue = true -var BoolFalse = false - // TestConfig returns a unique default configuration for testing an // agent. func TestConfig() *Config { @@ -335,6 +331,6 @@ func TestACLConfig() *Config { cfg.ACLMasterToken = "root" cfg.ACLAgentToken = "root" cfg.ACLAgentMasterToken = "towel" - cfg.ACLEnforceVersion8 = &BoolTrue + cfg.ACLEnforceVersion8 = Bool(true) return cfg }