Skip to content

Commit

Permalink
response test
Browse files Browse the repository at this point in the history
  • Loading branch information
evmar committed Oct 25, 2011
1 parent 645d94d commit eed02e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions imap/parser.go
Expand Up @@ -175,6 +175,7 @@ func (p *parser) readBracketed() (text string, outErr os.Error) {
check(p.expect("["))
text, err := p.ReadString(']')
check(err)
text = text[0:len(text)-1]

return text, nil
}
Expand Down
16 changes: 15 additions & 1 deletion imap/protocol_test.go
Expand Up @@ -3,6 +3,7 @@ package imap
import (
"bytes"
"testing"
"reflect"
)

func serverResponse(text string) *reader {
Expand All @@ -12,6 +13,19 @@ func serverResponse(text string) *reader {

func TestStatus(t *testing.T) {
r := serverResponse("* OK [PERMANENTFLAGS ()] Flags permitted.\r\n")
_, _, err := r.readResponse()
tag, resp, err := r.readResponse()
check(err)
if tag != untagged {
t.FailNow()
}

expected := &Response{
status: OK,
code: "PERMANENTFLAGS ()",
text: "Flags permitted.",
extra: nil,
}
if !reflect.DeepEqual(resp, expected) {
t.Fatalf("DeepEqual(%#v, %#v)", resp, expected)
}
}

0 comments on commit eed02e4

Please sign in to comment.