initial import
This commit is contained in:
27
core/discov/internal/statewatcher_test.go
Normal file
27
core/discov/internal/statewatcher_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
)
|
||||
|
||||
func TestStateWatcher_watch(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
watcher := newStateWatcher()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
watcher.addListener(func() {
|
||||
wg.Done()
|
||||
})
|
||||
conn := NewMocketcdConn(ctrl)
|
||||
conn.EXPECT().GetState().Return(connectivity.Ready)
|
||||
conn.EXPECT().GetState().Return(connectivity.TransientFailure)
|
||||
conn.EXPECT().GetState().Return(connectivity.Ready).AnyTimes()
|
||||
conn.EXPECT().WaitForStateChange(gomock.Any(), gomock.Any()).Return(true).AnyTimes()
|
||||
go watcher.watch(conn)
|
||||
wg.Wait()
|
||||
}
|
||||
Reference in New Issue
Block a user