-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1 developing test suite. Added tests for CAPABILITY and LOGOUT. Othe…
…r commands TODO.
- Loading branch information
twitchyliquid64
committed
Nov 4, 2014
1 parent
32a7fff
commit 304ad5b
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |