mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-18 09:47:41 +03:00
27 lines
442 B
Go
27 lines
442 B
Go
package chat
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
type MockScreen struct {
|
|
received []byte
|
|
}
|
|
|
|
func (s *MockScreen) Write(data []byte) (n int, err error) {
|
|
s.received = append(s.received, data...)
|
|
return len(data), nil
|
|
}
|
|
|
|
func TestMakeUser(t *testing.T) {
|
|
s := &MockScreen{}
|
|
u := NewUser("foo", s)
|
|
|
|
line := []byte("hello")
|
|
u.Write(line)
|
|
if !reflect.DeepEqual(s.received, line) {
|
|
t.Errorf("Expected hello but got: %s", s.received)
|
|
}
|
|
}
|