From ce4684a47ac13393e000d09da968ca5e00669d9f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 2 Jan 2017 03:21:40 -0500 Subject: [PATCH] Ensure stable message list order in pop3/conn_test.go. --- pop3/conn_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pop3/conn_test.go b/pop3/conn_test.go index 50115e7..5878eb5 100644 --- a/pop3/conn_test.go +++ b/pop3/conn_test.go @@ -9,6 +9,7 @@ import ( "path/filepath" "reflect" "runtime" + "sort" "strings" "testing" @@ -87,11 +88,24 @@ type testMailbox struct { msgs map[int]*testMessage } +type MessageList []Message + +func (l MessageList) Len() int { + return len(l) +} +func (l MessageList) Less(i, j int) bool { + return l[i].ID() < l[j].ID() +} +func (l MessageList) Swap(i, j int) { + l[i], l[j] = l[j], l[i] +} + func (mb *testMailbox) ListMessages() ([]Message, error) { msgs := make([]Message, 0, len(mb.msgs)) for i, _ := range mb.msgs { msgs = append(msgs, mb.msgs[i]) } + sort.Sort(MessageList(msgs)) return msgs, nil } -- 2.43.5