diff --git a/api/session_test.go b/api/session_test.go index 887660c94e..4d46c48ff9 100644 --- a/api/session_test.go +++ b/api/session_test.go @@ -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) {