test: add test with changing address order

This commit is contained in:
James Houlahan
2020-05-06 09:57:34 +02:00
parent c61e8bdc71
commit 2d200f6f8c
19 changed files with 202 additions and 23 deletions

View File

@ -146,6 +146,10 @@ func (a *TestAccount) AddressID() string {
return a.addressToBeUsed.ID
}
func (a *TestAccount) GetAddressID(addressTestID string) string {
return a.addressesByBDDAddressID[addressTestID].ID
}
// EnsureAddressID accepts address (simply the address) or bddAddressID used
// in tests (in format [bddAddressID]) and returns always the real address ID.
// If the address is not found, the ID of main address is returned.
@ -163,6 +167,10 @@ func (a *TestAccount) EnsureAddressID(addressOrAddressTestID string) string {
return a.AddressID()
}
func (a *TestAccount) GetAddress(addressTestID string) string {
return a.addressesByBDDAddressID[addressTestID].Email
}
// EnsureAddress accepts address (simply the address) or bddAddressID used
// in tests (in format [bddAddressID]) and returns always the address.
// If the address ID cannot be found, the original value is returned.

View File

@ -55,7 +55,8 @@ func (a *TestAccounts) GetTestAccount(username string) *TestAccount {
return a.GetTestAccountWithAddress(username, "")
}
func (a *TestAccounts) GetTestAccountWithAddress(username, addressID string) *TestAccount {
// GetTestAccount returns the test account with the given username configured to use the given bddAddressID.
func (a *TestAccounts) GetTestAccountWithAddress(username, bddAddressID string) *TestAccount {
// Do lookup by full address and convert to name in tests.
// Used by getting real data to ensure correct address or address ID.
for key, user := range a.Users {
@ -71,7 +72,7 @@ func (a *TestAccounts) GetTestAccountWithAddress(username, addressID string) *Te
return newTestAccount(
user,
a.Addresses[user.Name],
addressID,
bddAddressID,
a.Passwords[user.Name],
a.MailboxPasswords[user.Name],
a.TwoFAs[user.Name],