Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
outdead committed Jan 5, 2021
1 parent 09eba2b commit 8f7126c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (packet *Packet) WriteTo(w io.Writer) (n int64, err error) {
// ReadFrom implements io.ReaderFrom for read a packet from r.
func (packet *Packet) ReadFrom(r io.Reader) (n int64, err error) {
if err := binary.Read(r, binary.LittleEndian, &packet.Size); err != nil {
return n, fmt.Errorf("rcon: read packet size %w", err)
return n, fmt.Errorf("rcon: read packet size: %w", err)
}

n += 4
Expand All @@ -102,7 +102,7 @@ func (packet *Packet) ReadFrom(r io.Reader) (n int64, err error) {
}

if err := binary.Read(r, binary.LittleEndian, &packet.ID); err != nil {
return n, fmt.Errorf("rcon: read packet id %w", err)
return n, fmt.Errorf("rcon: read packet id: %w", err)
}

n += 4
Expand Down
4 changes: 2 additions & 2 deletions rcon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func TestConn_Execute(t *testing.T) {
conn.Close()

result, err := conn.Execute("help")
wantErrMsg := fmt.Sprintf("set tcp %s: use of closed network connection", conn.LocalAddr())
wantErrMsg := fmt.Sprintf("rcon: set tcp %s: use of closed network connection", conn.LocalAddr())
if err == nil || err.Error() != wantErrMsg {
t.Errorf("got err %q, want to contain %q", err, wantErrMsg)
}
Expand All @@ -211,7 +211,7 @@ func TestConn_Execute(t *testing.T) {
defer conn.Close()

result, err := conn.Execute("deadline")
wantErrMsg := fmt.Sprintf("read tcp %s->%s: i/o timeout", conn.LocalAddr(), conn.RemoteAddr())
wantErrMsg := fmt.Sprintf("rcon: read packet size: read tcp %s->%s: i/o timeout", conn.LocalAddr(), conn.RemoteAddr())
if err == nil || err.Error() != wantErrMsg {
t.Errorf("got err %q, want to contain %q", err, wantErrMsg)
}
Expand Down

0 comments on commit 8f7126c

Please sign in to comment.