-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
53 lines (43 loc) · 799 Bytes
/
main_test.go
File metadata and controls
53 lines (43 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"sync"
"testing"
"github.com/stretchr/testify/assert"
)
type MockLiftBridgeClient struct {
wg *sync.WaitGroup
}
func (mlbc MockLiftBridgeClient) Pub() {
defer mlbc.wg.Done()
fmt.Println("fake Pub() called")
}
func (mlbc MockLiftBridgeClient) Sub() {
defer mlbc.wg.Done()
fmt.Println("fake Sub() called")
}
func TestPub(t *testing.T) {
f := MockLiftBridgeClient{
wg: &sync.WaitGroup{},
}
f.wg.Add(1)
go pub(f)
assert.NotPanics(t, f.wg.Wait)
}
func TestSub(t *testing.T) {
f := MockLiftBridgeClient{
wg: &sync.WaitGroup{},
}
f.wg.Add(1)
go sub(f)
assert.NotPanics(t, f.wg.Wait)
}
func TestPubAndSub(t *testing.T) {
f := MockLiftBridgeClient{
wg: &sync.WaitGroup{},
}
f.wg.Add(2)
go pub(f)
go sub(f)
assert.NotPanics(t, f.wg.Wait)
}