pkg/storage/records: add unit test for Index

Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>
(cherry picked from commit c96aff6a43)
release-3.1
Zhou Hao 6 years ago committed by Matt Farina
parent 1303ae560e
commit 08865052eb
No known key found for this signature in database
GPG Key ID: 9436E80BFBA46909

@ -142,3 +142,34 @@ func TestRecordsGet(t *testing.T) {
}
}
}
func TestRecordsIndex(t *testing.T) {
rs := records([]*record{
newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.StatusSuperseded)),
newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.StatusDeployed)),
})
var tests = []struct {
desc string
key string
sort int
}{
{
"get valid key",
"rls-a.v1",
0,
},
{
"get invalid key",
"rls-a.v3",
-1,
},
}
for _, tt := range tests {
got, _ := rs.Index(tt.key)
if got != tt.sort {
t.Fatalf("Expected %d, got %d", tt.sort, got)
}
}
}

Loading…
Cancel
Save