fix test for breaking change: email is no longer unique (due to guest accounts)

This commit is contained in:
Frederik Löffert 2018-05-22 17:30:47 +02:00
parent d9247d3a04
commit 0b02171d77
2 changed files with 14 additions and 13 deletions

View File

@ -24,14 +24,19 @@ func TestCredentials(t *testing.T) {
if err != nil {
t.Fatal(err)
}
// Try to create credentials for already taken email.
// This should fail
email = "alice@bar.com"
password = "wonderland"
err = CreateCustomerCredentials(email, password)
if err == nil {
t.Fatal(err)
}
// ! ----------------------------------------------------------------------
// ~ due to non unique mails creating multiple creds with same mail is allowed now
// ! ----------------------------------------------------------------------
// // Try to create credentials for already taken email.
// // This should fail
// email = "alice@bar.com"
// password = "wonderland"
// err = CreateCustomerCredentials(email, password)
// if err == nil {
// t.Fatal(err)
// }
// Change email
err = ChangeEmail("foo@bar.com", "trent@bar.com")

View File

@ -11,8 +11,8 @@ import (
"github.com/foomo/shop/utils"
"github.com/foomo/shop/version"
"github.com/mitchellh/mapstructure"
"gopkg.in/mgo.v2/bson"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
// !! NOTE: customer must not import order !!
@ -246,10 +246,6 @@ func GetCustomerById(id string, customProvider CustomerCustomProvider) (*Custome
return findOneCustomer(&bson.M{"id": id}, nil, "", customProvider, false)
}
// GetCustomerByEmail // TODO this won't work for guests, because for guests there could be multiple entries for the same email address
func GetCustomerByEmail(email string, customProvider CustomerCustomProvider) (*Customer, error) {
return findOneCustomer(&bson.M{"email": email}, nil, "", customProvider, false)
}
func GetCurrentCustomerByIdFromVersionsHistory(customerId string, customProvider CustomerCustomProvider) (*Customer, error) {
return findOneCustomer(&bson.M{"id": customerId}, nil, "-version.current", customProvider, true)
}