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

Loading…
Cancel
Save