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 { 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)