Skip to content

Commit bd88f16

Browse files
committed
Update tests.
1 parent ed3cee6 commit bd88f16

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

cmd/aliasList.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func printAliases(aliases iredmail.Aliases) {
5757
table.Append([]string{a.Address, firstForwarding})
5858
for i := range a.Forwardings {
5959
if (i + 1) < len(a.Forwardings) {
60-
table.Append([]string{a.Address, a.Forwardings[i+1].Forwarding})
60+
table.Append([]string{"", a.Forwardings[i+1].Forwarding})
6161
}
6262
}
6363
}

integration_test/mailboxAddDelete_test.go

+59
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"path/filepath"
88
"reflect"
99
"strconv"
10+
"strings"
1011

1112
. "github.com/onsi/ginkgo"
1213
. "github.com/onsi/gomega"
@@ -250,6 +251,64 @@ var _ = Describe("mailbox add/delete", func() {
250251
}
251252
})
252253

254+
It("can't add an mailbox if an alias with same email exists", func() {
255+
if skipMailboxAddDelete && !isCI {
256+
Skip("can't add an mailbox if an alias with same email exists")
257+
}
258+
259+
cli := exec.Command(cliPath, "alias", "add", mailboxName1)
260+
output, err := cli.CombinedOutput()
261+
if err != nil {
262+
Fail(string(output))
263+
}
264+
265+
cli = exec.Command(cliPath, "mailbox", "add", mailboxName1, mailboxPW)
266+
output, err = cli.CombinedOutput()
267+
if err == nil {
268+
Fail("Expect an error")
269+
}
270+
actual := string(output)
271+
expected := fmt.Sprintf("An alias %s already exists\n", mailboxName1)
272+
273+
if !reflect.DeepEqual(actual, expected) {
274+
Fail(fmt.Sprintf("actual = %s, expected = %s", actual, expected))
275+
}
276+
})
277+
278+
It("can't add an mailbox if an mailbox alias with same email exists", func() {
279+
if skipMailboxAddDelete && !isCI {
280+
Skip("can't add an mailbox if an mailbox alias with same email exists")
281+
}
282+
283+
splitMail := strings.Split(mailboxName1, "@")
284+
name, domain := splitMail[0], splitMail[1]
285+
mailboxName := "othername@" + domain
286+
287+
cli := exec.Command(cliPath, "mailbox", "add", mailboxName, mailboxPW)
288+
output, err := cli.CombinedOutput()
289+
if err != nil {
290+
Fail(string(output))
291+
}
292+
293+
cli = exec.Command(cliPath, "mailbox", "add-alias", name, mailboxName)
294+
output, err = cli.CombinedOutput()
295+
if err != nil {
296+
Fail(string(output))
297+
}
298+
299+
cli = exec.Command(cliPath, "mailbox", "add", mailboxName1, mailboxPW)
300+
output, err = cli.CombinedOutput()
301+
if err == nil {
302+
Fail("Expect an error")
303+
}
304+
actual := string(output)
305+
expected := fmt.Sprintf("A mailbox alias %s already exists\n", mailboxName1)
306+
307+
if !reflect.DeepEqual(actual, expected) {
308+
Fail(fmt.Sprintf("actual = %s, expected = %s", actual, expected))
309+
}
310+
})
311+
253312
It("can add an mailbox with custom quota", func() {
254313
if skipMailboxAddDelete && !isCI {
255314
Skip("can add an mailbox with custom quota")

0 commit comments

Comments
 (0)