From d0842e7b00057e713f8eebbca5c3ef7f48ec0408 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Thu, 13 Sep 2018 17:27:14 -0700 Subject: [PATCH] test: cleanup mock consul service client Updated to hclog. It exposed fields that required an unexported lock to access. Created a getter methodn instead. Only old allocrunner currently used this feature. --- client/consul/consul_testing.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/consul/consul_testing.go b/client/consul/consul_testing.go index a7997a3eb..f161b6f08 100644 --- a/client/consul/consul_testing.go +++ b/client/consul/consul_testing.go @@ -31,7 +31,7 @@ func NewMockConsulOp(op, allocID, task string) MockConsulOp { // MockConsulServiceClient implements the ConsulServiceAPI interface to record // and log task registration/deregistration. type MockConsulServiceClient struct { - Ops []MockConsulOp + ops []MockConsulOp mu sync.Mutex logger log.Logger @@ -85,3 +85,9 @@ func (m *MockConsulServiceClient) AllocRegistrations(allocID string) (*consul.Al return nil, nil } + +func (m *MockConsulServiceClient) GetOps() []MockConsulOp { + m.mu.Lock() + defer m.mu.Unlock() + return m.ops +}