Skip to content

Commit

Permalink
TestKeyspaceStringParser
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver006 committed Oct 29, 2024
1 parent a4d4971 commit 11f6e78
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion exporter/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ func TestKeyspaceStringParser(t *testing.T) {

{db: "db0", stats: "keys=1,expires=0,avg_ttl=0", keysTotal: 1, keysEx: 0, avgTTL: 0, keysCached: -1, ok: true},
{db: "db0", stats: "keys=1,expires=0,avg_ttl=0,cached_keys=0", keysTotal: 1, keysEx: 0, avgTTL: 0, keysCached: 0, ok: true},

{
db: "db0", stats: "keys=25714011,expires=25091314,avg_ttl=685620459,subexpiry=0",
keysTotal: 25714011, keysEx: 25091314, keysCached: 0, avgTTL: 685620.459000,
ok: true,
},
}

log.SetLevel(log.DebugLevel)
for _, tst := range tsts {
if kt, kx, ttl, kc, ok := parseDBKeyspaceString(tst.db, tst.stats); true {

Expand All @@ -46,7 +53,12 @@ func TestKeyspaceStringParser(t *testing.T) {
}

if ok && (kt != tst.keysTotal || kx != tst.keysEx || kc != tst.keysCached || ttl != tst.avgTTL) {
t.Errorf("values not matching, db:%s stats:%s %f %f %f %f", tst.db, tst.stats, kt, kx, kc, ttl)
t.Errorf("values not matching, db:%s stats:%s %f != %f %f != %f %f != %f %f != %f",
tst.db, tst.stats,
kt, tst.keysTotal,
kx, tst.keysEx,
kc, tst.keysCached,
ttl, tst.avgTTL)
}
}
}
Expand Down

0 comments on commit 11f6e78

Please sign in to comment.