Skip to content

Commit

Permalink
alienscience#1 developing test suite. Added tests for CAPABILITY and …
Browse files Browse the repository at this point in the history
…LOGOUT. Other commands TODO.
  • Loading branch information
twitchyliquid64 authored and Alexandru Plugaru committed Nov 4, 2014
1 parent 845b64d commit 879214a
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions command_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package imapsrv

import "testing"
import "fmt"



func setupTest() (*Server,*session){
m := &TestMailstore{}
s := NewServer(
Store(m),
)
//s.Start()
sess := createSession(1, s.config)
return s, sess
}



// A test mailstore used for unit testing
type TestMailstore struct {
}

// Get mailbox information
func (m *TestMailstore) GetMailbox(name string) (*Mailbox, error) {
return &Mailbox{
Name: "inbox",
Id: 1,
}, nil
}

// Get the sequence number of the first unseen message
func (m *TestMailstore) FirstUnseen(mbox int64) (int64, error) {
return 4, nil
}

// Get the total number of messages in an IMAP mailbox
func (m *TestMailstore) TotalMessages(mbox int64) (int64, error) {
return 8, nil
}

// Get the total number of unread messages in an IMAP mailbox
func (m *TestMailstore) RecentMessages(mbox int64) (int64, error) {
return 4, nil
}

// Get the next available uid in an IMAP mailbox
func (m *TestMailstore) NextUid(mbox int64) (int64, error) {
return 9, nil
}




func TestCapabilityCommand( t *testing.T){
_, session := setupTest()
cap := &capability{tag: "A00001"}
resp := cap.execute(session)
if (resp.tag != "A00001") || (resp.message != "CAPABILITY completed") || (resp.untagged[0] != "CAPABILITY IMAP4rev1"){
t.Error("Capability Failed - unexpected response.")
}
fmt.Println(resp)
//t.Error("Load() did not error, should have fileNotFound")
}

0 comments on commit 879214a

Please sign in to comment.