Tightens up the API test verification.

This commit is contained in:
James Phillips 2017-12-14 07:50:41 -08:00
parent ca3f9024ac
commit 53a881becc
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
1 changed files with 20 additions and 47 deletions

View File

@ -5,6 +5,8 @@ import (
"strings"
"testing"
"time"
"github.com/pascaldekloe/goe/verify"
)
func TestAPI_SessionCreateDestroy(t *testing.T) {
@ -289,7 +291,6 @@ func TestAPI_SessionInfo(t *testing.T) {
if err != nil {
t.Fatalf("err: %v", err)
}
if qm.LastIndex == 0 {
t.Fatalf("bad: %v", qm)
}
@ -297,33 +298,19 @@ func TestAPI_SessionInfo(t *testing.T) {
t.Fatalf("bad: %v", qm)
}
if info == nil {
t.Fatalf("should get session")
}
if info.CreateIndex == 0 {
t.Fatalf("bad: %v", info)
}
if info.ID != id {
t.Fatalf("bad: %v", info)
}
if info.Name != "" {
t.Fatalf("bad: %v", info)
}
if info.Node == "" {
t.Fatalf("bad: %v", info)
}
if len(info.Checks) == 0 {
t.Fatalf("bad: %v", info)
}
if info.LockDelay == 0 {
t.Fatalf("bad: %v", info)
}
if info.Behavior != "release" {
t.Fatalf("bad: %v", info)
}
if info.TTL != "" {
t.Fatalf("bad: %v", info)
info.CreateIndex = 0
want := &SessionEntry{
ID: id,
Node: s.Config.NodeName,
Checks: []string{"serfHealth"},
LockDelay: 15 * time.Second,
Behavior: SessionBehaviorRelease,
}
verify.Values(t, "", info, want)
}
func TestAPI_SessionInfo_NoChecks(t *testing.T) {
@ -351,33 +338,19 @@ func TestAPI_SessionInfo_NoChecks(t *testing.T) {
t.Fatalf("bad: %v", qm)
}
if info == nil {
t.Fatalf("should get session")
}
if info.CreateIndex == 0 {
t.Fatalf("bad: %v", info)
}
if info.ID != id {
t.Fatalf("bad: %v", info)
}
if info.Name != "" {
t.Fatalf("bad: %v", info)
}
if info.Node == "" {
t.Fatalf("bad: %v", info)
}
if len(info.Checks) != 0 {
t.Fatalf("bad: %v", info)
}
if info.LockDelay == 0 {
t.Fatalf("bad: %v", info)
}
if info.Behavior != "release" {
t.Fatalf("bad: %v", info)
}
if info.TTL != "" {
t.Fatalf("bad: %v", info)
info.CreateIndex = 0
want := &SessionEntry{
ID: id,
Node: s.Config.NodeName,
Checks: []string{},
LockDelay: 15 * time.Second,
Behavior: SessionBehaviorRelease,
}
verify.Values(t, "", info, want)
}
func TestAPI_SessionNode(t *testing.T) {