Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
drlogout committed Jul 10, 2018
1 parent ed3cee6 commit bd88f16
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/aliasList.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func printAliases(aliases iredmail.Aliases) {
table.Append([]string{a.Address, firstForwarding})
for i := range a.Forwardings {
if (i + 1) < len(a.Forwardings) {
table.Append([]string{a.Address, a.Forwardings[i+1].Forwarding})
table.Append([]string{"", a.Forwardings[i+1].Forwarding})
}
}
}
Expand Down
59 changes: 59 additions & 0 deletions integration_test/mailboxAddDelete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"
"reflect"
"strconv"
"strings"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -250,6 +251,64 @@ var _ = Describe("mailbox add/delete", func() {
}
})

It("can't add an mailbox if an alias with same email exists", func() {
if skipMailboxAddDelete && !isCI {
Skip("can't add an mailbox if an alias with same email exists")
}

cli := exec.Command(cliPath, "alias", "add", mailboxName1)
output, err := cli.CombinedOutput()
if err != nil {
Fail(string(output))
}

cli = exec.Command(cliPath, "mailbox", "add", mailboxName1, mailboxPW)
output, err = cli.CombinedOutput()
if err == nil {
Fail("Expect an error")
}
actual := string(output)
expected := fmt.Sprintf("An alias %s already exists\n", mailboxName1)

if !reflect.DeepEqual(actual, expected) {
Fail(fmt.Sprintf("actual = %s, expected = %s", actual, expected))
}
})

It("can't add an mailbox if an mailbox alias with same email exists", func() {
if skipMailboxAddDelete && !isCI {
Skip("can't add an mailbox if an mailbox alias with same email exists")
}

splitMail := strings.Split(mailboxName1, "@")
name, domain := splitMail[0], splitMail[1]
mailboxName := "othername@" + domain

cli := exec.Command(cliPath, "mailbox", "add", mailboxName, mailboxPW)
output, err := cli.CombinedOutput()
if err != nil {
Fail(string(output))
}

cli = exec.Command(cliPath, "mailbox", "add-alias", name, mailboxName)
output, err = cli.CombinedOutput()
if err != nil {
Fail(string(output))
}

cli = exec.Command(cliPath, "mailbox", "add", mailboxName1, mailboxPW)
output, err = cli.CombinedOutput()
if err == nil {
Fail("Expect an error")
}
actual := string(output)
expected := fmt.Sprintf("A mailbox alias %s already exists\n", mailboxName1)

if !reflect.DeepEqual(actual, expected) {
Fail(fmt.Sprintf("actual = %s, expected = %s", actual, expected))
}
})

It("can add an mailbox with custom quota", func() {
if skipMailboxAddDelete && !isCI {
Skip("can add an mailbox with custom quota")
Expand Down

0 comments on commit bd88f16

Please sign in to comment.