traefik/old/provider/kv/kv_test.go

55 lines
1.1 KiB
Go
Raw Normal View History

package kv
import (
"testing"
"time"
"github.com/abronan/valkeyrie/store"
2018-11-14 09:18:03 +00:00
"github.com/containous/traefik/old/log"
"github.com/containous/traefik/old/types"
)
func TestKvWatchTree(t *testing.T) {
t.Skip("Old")
returnedChans := make(chan chan []*store.KVPair)
provider := Provider{
kvClient: &Mock{
WatchTreeMethod: func() <-chan []*store.KVPair {
c := make(chan []*store.KVPair, 10)
returnedChans <- c
return c
},
},
}
configChan := make(chan types.ConfigMessage)
go func() {
2018-08-06 18:00:03 +00:00
if err := provider.watchKv(configChan, "prefix", make(chan bool, 1)); err != nil {
log.Error(err)
}
}()
select {
case c1 := <-returnedChans:
c1 <- []*store.KVPair{}
<-configChan
close(c1) // WatchTree chans can close due to error
case <-time.After(1 * time.Second):
2016-03-05 20:43:44 +00:00
t.Fatalf("Failed to create a new WatchTree chan")
}
select {
case c2 := <-returnedChans:
c2 <- []*store.KVPair{}
<-configChan
case <-time.After(1 * time.Second):
2016-03-05 20:43:44 +00:00
t.Fatalf("Failed to create a new WatchTree chan")
}
select {
2017-08-18 00:18:02 +00:00
case <-configChan:
t.Fatalf("configChan should be empty")
default:
}
}