Tightens up the API test verification.

pull/3747/head
James Phillips 7 years ago
parent ca3f9024ac
commit 53a881becc
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11

@ -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) {

Loading…
Cancel
Save