From 281fc9837ca52efffc4ad137564a7c6b9f331207 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Wed, 25 Mar 2020 08:29:25 -0400 Subject: [PATCH] tests: relax index checks TestStateStore_Indexes specifically tests for `nodes` index, but asserts on the exact number of indexes present in the state. This is fragile and will break almost everytime we add a state index. --- nomad/state/state_store_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nomad/state/state_store_test.go b/nomad/state/state_store_test.go index ac60093f5..282e67d3c 100644 --- a/nomad/state/state_store_test.go +++ b/nomad/state/state_store_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/hashicorp/go-memdb" + "github.com/kr/pretty" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -3137,8 +3138,8 @@ func TestStateStore_Indexes(t *testing.T) { } expect := &IndexEntry{"nodes", 1000} - if l := len(out); l != 1 && l != 2 { - t.Fatalf("unexpected number of index entries: %v", out) + if l := len(out); l < 1 { + t.Fatalf("unexpected number of index entries: %v", pretty.Sprint(out)) } for _, index := range out {