Skip to content

Commit 5961017

Browse files
committed
enable example tests
1 parent ee0fb71 commit 5961017

31 files changed

+473
-305
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test.ci:
1717
(cd "$${dir}" && \
1818
go mod tidy -compat=1.18 && \
1919
go vet && \
20-
go test -coverprofile=coverage.txt -covermode=atomic ./... -race -skip Example*); \
20+
go test -coverprofile=coverage.txt -covermode=atomic ./... -race); \
2121
done
2222
cd internal/customvet && go build .
2323
go vet -vettool ./internal/customvet/customvet

doctests/bf_tutorial_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func ExampleClient_bloom() {
2121
})
2222

2323
// REMOVE_START
24+
// make sure we are working with fresh database
25+
rdb.FlushDB(ctx)
2426
rdb.Del(ctx, "bikes:models")
2527
// REMOVE_END
2628

doctests/bitfield_tutorial_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func ExampleClient_bf() {
2121
})
2222

2323
// REMOVE_START
24+
// make sure we are working with fresh database
25+
rdb.FlushDB(ctx)
2426
rdb.Del(ctx, "bike:1:stats")
2527
// REMOVE_END
2628

doctests/bitmap_tutorial_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func ExampleClient_ping() {
2121
})
2222

2323
// REMOVE_START
24+
// make sure we are working with fresh database
25+
rdb.FlushDB(ctx)
2426
rdb.Del(ctx, "pings:2024-01-01-00:00")
2527
// REMOVE_END
2628

@@ -66,6 +68,8 @@ func ExampleClient_bitcount() {
6668
})
6769

6870
// REMOVE_START
71+
// start with fresh database
72+
rdb.FlushDB(ctx)
6973
_, err := rdb.SetBit(ctx, "pings:2024-01-01-00:00", 123, 1).Result()
7074

7175
if err != nil {

doctests/cmds_generic_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ func ExampleClient_del_cmd() {
2323
})
2424

2525
// REMOVE_START
26+
// make sure we are working with fresh database
27+
rdb.FlushDB(ctx)
2628
rdb.Del(ctx, "key1", "key2", "key3")
2729
// REMOVE_END
2830

@@ -68,6 +70,8 @@ func ExampleClient_expire_cmd() {
6870
})
6971

7072
// REMOVE_START
73+
// start with fresh database
74+
rdb.FlushDB(ctx)
7175
rdb.Del(ctx, "mykey")
7276
// REMOVE_END
7377

@@ -167,6 +171,8 @@ func ExampleClient_ttl_cmd() {
167171
})
168172

169173
// REMOVE_START
174+
// start with fresh database
175+
rdb.FlushDB(ctx)
170176
rdb.Del(ctx, "mykey")
171177
// REMOVE_END
172178

doctests/cmds_hash_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func ExampleClient_hset() {
2222
})
2323

2424
// REMOVE_START
25+
// make sure we are working with fresh database
26+
rdb.FlushDB(ctx)
2527
rdb.Del(ctx, "myhash")
2628
// REMOVE_END
2729

@@ -112,6 +114,8 @@ func ExampleClient_hget() {
112114
})
113115

114116
// REMOVE_START
117+
// start with fresh database
118+
rdb.FlushDB(ctx)
115119
rdb.Del(ctx, "myhash")
116120
// REMOVE_END
117121

@@ -157,6 +161,8 @@ func ExampleClient_hgetall() {
157161
})
158162

159163
// REMOVE_START
164+
// start with fresh database
165+
rdb.FlushDB(ctx)
160166
rdb.Del(ctx, "myhash")
161167
// REMOVE_END
162168

@@ -209,6 +215,8 @@ func ExampleClient_hvals() {
209215
})
210216

211217
// REMOVE_START
218+
// start with fresh database
219+
rdb.FlushDB(ctx)
212220
rdb.Del(ctx, "myhash")
213221
// REMOVE_END
214222

doctests/cmds_servermgmt_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func ExampleClient_cmd_flushall() {
2222

2323
// STEP_START flushall
2424
// REMOVE_START
25+
// make sure we are working with fresh database
26+
rdb.FlushDB(ctx)
2527
rdb.Set(ctx, "testkey1", "1", 0)
2628
rdb.Set(ctx, "testkey2", "2", 0)
2729
rdb.Set(ctx, "testkey3", "3", 0)

doctests/cmds_sorted_set_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func ExampleClient_zadd_cmd() {
2121
})
2222

2323
// REMOVE_START
24+
// make sure we are working with fresh database
25+
rdb.FlushDB(ctx)
2426
rdb.Del(ctx, "myzset")
2527
// REMOVE_END
2628

@@ -82,6 +84,8 @@ func ExampleClient_zrange1() {
8284
})
8385

8486
// REMOVE_START
87+
// start with fresh database
88+
rdb.FlushDB(ctx)
8589
rdb.Del(ctx, "myzset")
8690
// REMOVE_END
8791

@@ -140,6 +144,8 @@ func ExampleClient_zrange2() {
140144
})
141145

142146
// REMOVE_START
147+
// start with fresh database
148+
rdb.FlushDB(ctx)
143149
rdb.Del(ctx, "myzset")
144150
// REMOVE_END
145151

@@ -180,6 +186,8 @@ func ExampleClient_zrange3() {
180186
})
181187

182188
// REMOVE_START
189+
// start with fresh database
190+
rdb.FlushDB(ctx)
183191
rdb.Del(ctx, "myzset")
184192
// REMOVE_END
185193

doctests/cmds_string_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func ExampleClient_cmd_incr() {
2121
})
2222

2323
// REMOVE_START
24+
// make sure we are working with fresh database
25+
rdb.FlushDB(ctx)
2426
rdb.Del(ctx, "mykey")
2527
// REMOVE_END
2628

doctests/cms_tutorial_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ func ExampleClient_cms() {
2121
})
2222

2323
// REMOVE_START
24+
// make sure we are working with fresh database
25+
rdb.FlushDB(ctx)
2426
rdb.Del(ctx, "bikes:profit")
2527
// REMOVE_END
2628

0 commit comments

Comments
 (0)