forked from boyska/circolog
refactor unit test
This commit is contained in:
parent
504af5cce6
commit
f31b2fb74f
1 changed files with 8 additions and 10 deletions
18
hub_test.go
18
hub_test.go
|
@ -11,19 +11,14 @@ func msg(s string) format.LogParts {
|
||||||
}
|
}
|
||||||
|
|
||||||
func hubCount(h Hub) int {
|
func hubCount(h Hub) int {
|
||||||
cl := Client{Options: ClientOptions{Nofollow: true, BacklogLength: -1}}
|
return len(hubToArray(h))
|
||||||
cl.Messages = make(chan format.LogParts)
|
|
||||||
h.Register <- cl
|
|
||||||
cnt := 0
|
|
||||||
for range cl.Messages {
|
|
||||||
cnt++
|
|
||||||
}
|
|
||||||
return cnt
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func hubToArray(h Hub) []string {
|
var DefaultClient ClientOptions = ClientOptions{Nofollow: true, BacklogLength: -1}
|
||||||
|
|
||||||
|
func hubToArrayOpt(h Hub, opt ClientOptions) []string {
|
||||||
r := make([]string, 0)
|
r := make([]string, 0)
|
||||||
cl := Client{Options: ClientOptions{Nofollow: true, BacklogLength: -1}}
|
cl := Client{Options: opt}
|
||||||
cl.Messages = make(chan format.LogParts)
|
cl.Messages = make(chan format.LogParts)
|
||||||
h.Register <- cl
|
h.Register <- cl
|
||||||
for m := range cl.Messages {
|
for m := range cl.Messages {
|
||||||
|
@ -31,6 +26,9 @@ func hubToArray(h Hub) []string {
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
func hubToArray(h Hub) []string {
|
||||||
|
return hubToArrayOpt(h, DefaultClient)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSingle(t *testing.T) {
|
func TestSingle(t *testing.T) {
|
||||||
h := NewHub(5)
|
h := NewHub(5)
|
||||||
|
|
Loading…
Reference in a new issue