Skip to content

Commit 0999526

Browse files
committed
bump up test coverage to 98.1%
1 parent b3f4e08 commit 0999526

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pattern_test.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ func TestRegexp(t *testing.T) {
99
db.Set("card:1:black_lotus", "Black Lotus")
1010
db.Set("card:2:mox_pearl", "Mox Pearl")
1111

12+
// feed in some bad regexp to MatchKeys
1213
badRegexp := "card[0-9"
1314
_, err := db.MatchKeys(badRegexp)
1415
if err == nil {
1516
t.Errorf("expected error, got nil")
1617
}
1718

19+
// feed in some bad regexp to MatchValues
1820
_, err = db.MatchValues(badRegexp)
1921
if err == nil {
2022
t.Errorf("expected error, got nil")
2123
}
2224

25+
// fetch both cards by key
2326
keys, err := db.MatchKeys("card:[0-9]:.")
2427
if err != nil {
2528
t.Error(err)
@@ -28,6 +31,7 @@ func TestRegexp(t *testing.T) {
2831
t.Errorf("expected %d, got %d", 2, len(keys))
2932
}
3033

34+
// fetch both cards by value
3135
values, err := db.MatchValues("card:[0-9]:.")
3236
if err != nil {
3337
t.Error(err)
@@ -42,6 +46,7 @@ func TestPrefix(t *testing.T) {
4246
db.Set("card:1:black_lotus", "Black Lotus")
4347
db.Set("card:2:mox_pearl", "Mox Pearl")
4448

49+
// fetch one card by prefix exact match
4550
keys, err := db.Prefix("card:2:mox_pearl")
4651
if err != nil {
4752
t.Error(err)
@@ -51,6 +56,7 @@ func TestPrefix(t *testing.T) {
5156
t.Errorf("expected %d, got %d", 1, len(keys))
5257
}
5358

59+
// fetch both cards by prefix using wildcards
5460
keys, err = db.Prefix("*:?:*")
5561
if err != nil {
5662
t.Error(err)
@@ -60,7 +66,8 @@ func TestPrefix(t *testing.T) {
6066
t.Errorf("expected %d, got %d", 2, len(keys))
6167
}
6268

63-
keysChan := db.PrefixChan("c?")
69+
// fetch both cards by prefix to a channel using wildcards
70+
keysChan := db.PrefixChan("*:?:*")
6471
count := 0
6572
for range keysChan {
6673
count++

0 commit comments

Comments
 (0)