func TestHandle(t *testing.T) {
	socketTests := []struct {
		handle     func(s Socket, m message.Message)
		wantCallID int
	}{
		{
			handle:     func(s Socket, m message.Message) { s.handleGameLeave(m) },
			wantCallID: 1,
		},
		{
			handle:     func(s Socket, m message.Message) { s.handlePlayerRemove(m) },
			wantCallID: 1,
		},
		{
			handle:     func(s Socket, m message.Message) { s.handleInfo(m) },
			wantCallID: 2,
		},
	}
	for _, subTest := range socketTests {
		handleTests := []struct {
			info    string
			wantLog bool
		}{
			{},
			{
				info:    "stuff to log",
				wantLog: true,
			},
		}
		for i, test := range handleTests {
			callID := 0
			infoLogged := false
			m := message.Message{
				Info: test.info,
			}
			s := Socket{
				game: &mockGame{
					LeaveFunc: func() {
						callID = 1
					},
					UpdateInfoFunc: func(msg message.Message) {
						callID = 2
					},
				},
				log: &mockLog{
					InfoFunc: func(text string) {
						if want, got := test.info, text; want != got {
							t.Errorf("Test %v: logged info not equal: wanted %v, got %v", i, want, got)
						}
						infoLogged = true
					},
				},
			}
			subTest.handle(s, m)
			if want, got := subTest.wantCallID, callID; want != got {
				t.Errorf("Test %v: wanted call %v to be made, got %v", i, want, got)
			}
			if want, got := test.wantLog, infoLogged; want != got {
				t.Errorf("Test %v: log.info() call not equal: wanted %v, got %v", i, want, got)
			}
		}
	}
}
// TestHandle tests handleGameLeave, handlePlayerRemove and handleInfo
TestHandle tests handleGameLeave, handlePlayerRemove and handleInfo
// TestHandle tests handleGameLeave handlePlayerRemove and handleInfo
func TestHandle(t *testing.T) {
	socketTests := []struct {
		handle     func(s Socket, m message.Message)
		wantCallID int
	}{
		{
			handle:     func(s Socket, m message.Message) { s.handleGameLeave(m) },
			wantCallID: 1,
		},
		{
			handle:     func(s Socket, m message.Message) { s.handlePlayerRemove(m) },
			wantCallID: 1,
		},
		{
			handle:     func(s Socket, m message.Message) { s.handleInfo(m) },
			wantCallID: 2,
		},
	}
	for _, subTest := range socketTests {
		handleTests := []struct {
			info    string
			wantLog bool
		}{
			{},
			{
				info:    "stuff to log",
				wantLog: true,
			},
		}
		for i, test := range handleTests {
			callID := 0
			infoLogged := false
			m := message.Message{
				Info: test.info,
			}
			s := Socket{
				game: &mockGame{
					LeaveFunc: func() {
						callID = 1
					},
					UpdateInfoFunc: func(msg message.Message) {
						callID = 2
					},
				},
				log: &mockLog{
					InfoFunc: func(text string) {
						if want, got := test.info, text; want != got {
							t.Errorf("Test %v: logged info not equal: wanted %v, got %v", i, want, got)
						}
						infoLogged = true
					},
				},
			}
			subTest.handle(s, m)
			if want, got := subTest.wantCallID, callID; want != got {
				t.Errorf("Test %v: wanted call %v to be made, got %v", i, want, got)
			}
			if want, got := test.wantLog, infoLogged; want != got {
				t.Errorf("Test %v: log.info() call not equal: wanted %v, got %v", i, want, got)
			}
		}
	}
}
func TestHandle ( t * testing . T ) { socketTests := [ ] struct { handle func ( s Socket , m message . Message ) wantCallID int } { { handle : func ( s Socket , m message . Message ) { s . handleGameLeave ( m ) } , wantCallID : 1 , } , { handle : func ( s Socket , m message . Message ) { s . handlePlayerRemove ( m ) } , wantCallID : 1 , } , { handle : func ( s Socket , m message . Message ) { s . handleInfo ( m ) } , wantCallID : 2 , } , } for _ , subTest := range socketTests { handleTests := [ ] struct { info string wantLog bool } { { } , { info : " " , wantLog : true , } , } for i , test := range handleTests { callID := 0 infoLogged := false m := message . Message { Info : test . info , } s := Socket { game : & mockGame { LeaveFunc : func ( ) { callID = 1 } , UpdateInfoFunc : func ( msg message . Message ) { callID = 2 } , } , log : & mockLog { InfoFunc : func ( text string ) { if want , got := test . info , text ; want != got { t . Errorf ( " " , i , want , got ) } infoLogged = true } , } , } subTest . handle ( s , m ) if want , got := subTest . wantCallID , callID ; want != got { t . Errorf ( " " , i , want , got ) } if want , got := test . wantLog , infoLogged ; want != got { t . Errorf ( " " , i , want , got ) } } } }
TestHandle tests handleGameLeave, handlePlayerRemove and handleInfo
TestHandle tests handleGameLeave handlePlayerRemove and handleInfo