mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-18 17:57:41 +03:00
28 lines
458 B
Go
28 lines
458 B
Go
package chat
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestChannel(t *testing.T) {
|
|
s := &MockScreen{}
|
|
out := make(chan Message)
|
|
defer close(out)
|
|
|
|
go func() {
|
|
for msg := range out {
|
|
s.Write([]byte(msg.Render(nil)))
|
|
}
|
|
}()
|
|
|
|
u := NewUser("foo", s)
|
|
ch := NewChannel("", out)
|
|
ch.Join(u)
|
|
|
|
expected := []byte(" * foo joined. (Connected: 1)")
|
|
if !reflect.DeepEqual(s.received, expected) {
|
|
t.Errorf("Got: %s, Expected: %s", s.received, expected)
|
|
}
|
|
}
|