Skip to content

Commit 8b166cb

Browse files
committed
singleflight_test: add rudimentary checking for refShared
1 parent f08e0ce commit 8b166cb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

singleflight/singleflight_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
func TestDo(t *testing.T) {
1717
var g Group
18-
v, err, _ := g.Do("key", func() (interface{}, error) {
18+
v, err, shared := g.Do("key", func() (interface{}, error) {
1919
return "bar", nil
2020
})
2121
if got, want := fmt.Sprintf("%v (%T)", v, v), "bar (string)"; got != want {
@@ -24,6 +24,12 @@ func TestDo(t *testing.T) {
2424
if err != nil {
2525
t.Errorf("Do error = %v", err)
2626
}
27+
if shared.Decrement() != 0 {
28+
t.Errorf("ref counter is expected to be 0")
29+
}
30+
if shared.Shared() {
31+
t.Errorf("Do returned shared")
32+
}
2733
}
2834

2935
func TestDoErr(t *testing.T) {

0 commit comments

Comments
 (0)