refactor unit test

This commit is contained in:
boyska 2018-11-08 19:49:29 +01:00
parent 504af5cce6
commit f31b2fb74f

View file

@ -11,19 +11,14 @@ func msg(s string) format.LogParts {
}
func hubCount(h Hub) int {
cl := Client{Options: ClientOptions{Nofollow: true, BacklogLength: -1}}
cl.Messages = make(chan format.LogParts)
h.Register <- cl
cnt := 0
for range cl.Messages {
cnt++
}
return cnt
return len(hubToArray(h))
}
func hubToArray(h Hub) []string {
var DefaultClient ClientOptions = ClientOptions{Nofollow: true, BacklogLength: -1}
func hubToArrayOpt(h Hub, opt ClientOptions) []string {
r := make([]string, 0)
cl := Client{Options: ClientOptions{Nofollow: true, BacklogLength: -1}}
cl := Client{Options: opt}
cl.Messages = make(chan format.LogParts)
h.Register <- cl
for m := range cl.Messages {
@ -31,6 +26,9 @@ func hubToArray(h Hub) []string {
}
return r
}
func hubToArray(h Hub) []string {
return hubToArrayOpt(h, DefaultClient)
}
func TestSingle(t *testing.T) {
h := NewHub(5)