agent/consul/state: convert proxy test to testify/assert

This commit is contained in:
Mitchell Hashimoto 2018-03-06 17:13:52 -08:00
parent 09568ce7b5
commit 58bff8dd05
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 8 additions and 12 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/hashicorp/go-memdb" "github.com/hashicorp/go-memdb"
uuid "github.com/hashicorp/go-uuid" uuid "github.com/hashicorp/go-uuid"
"github.com/pascaldekloe/goe/verify" "github.com/pascaldekloe/goe/verify"
"github.com/stretchr/testify/assert"
) )
func makeRandomNodeID(t *testing.T) types.NodeID { func makeRandomNodeID(t *testing.T) types.NodeID {
@ -982,6 +983,7 @@ func TestStateStore_EnsureService(t *testing.T) {
} }
func TestStateStore_EnsureService_connectProxy(t *testing.T) { func TestStateStore_EnsureService_connectProxy(t *testing.T) {
assert := assert.New(t)
s := testStateStore(t) s := testStateStore(t)
// Create the service registration. // Create the service registration.
@ -996,23 +998,17 @@ func TestStateStore_EnsureService_connectProxy(t *testing.T) {
// Service successfully registers into the state store. // Service successfully registers into the state store.
testRegisterNode(t, s, 0, "node1") testRegisterNode(t, s, 0, "node1")
if err := s.EnsureService(10, "node1", ns1); err != nil { assert.Nil(s.EnsureService(10, "node1", ns1))
t.Fatalf("err: %s", err)
}
// Retrieve and verify // Retrieve and verify
_, out, err := s.NodeServices(nil, "node1") _, out, err := s.NodeServices(nil, "node1")
if err != nil { assert.Nil(err)
t.Fatalf("err: %s", err) assert.NotNil(out)
} assert.Len(out.Services, 1)
if out == nil || len(out.Services) != 1 {
t.Fatalf("bad: %#v", out)
}
expect1 := *ns1 expect1 := *ns1
expect1.CreateIndex, expect1.ModifyIndex = 10, 10 expect1.CreateIndex, expect1.ModifyIndex = 10, 10
if svc := out.Services["connect-proxy"]; !reflect.DeepEqual(&expect1, svc) { assert.Equal(&expect1, out.Services["connect-proxy"])
t.Fatalf("bad: %#v", svc)
}
} }
func TestStateStore_Services(t *testing.T) { func TestStateStore_Services(t *testing.T) {