Created
July 15, 2016 11:20
-
-
Save kavirajk/24e79d3616204238ccaa232eb64619c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"testing" | |
"code.launchyard.com/root/myserver/utils" | |
"code.launchyard.com/root/myserver/models" | |
) | |
func TestResetPassword(t *testing.T) { | |
save_password_called := false | |
var user *models.User | |
new_password := "jedi" | |
// userGetter mock | |
userGetter = func(email string) *models.User { | |
user = &models.User{Password: "old_password", Email: email} | |
return user | |
} | |
// savePassword mock | |
savePassword = func(s Saver) { | |
save_password_called = true | |
} | |
ResetPassword("[email protected]", new_password) | |
expected := utils.HashString("jedi") | |
if user == nil { | |
t.Fatalf("userGetter not called") | |
} | |
if !save_password_called { | |
t.Errorf("savePassword not called") | |
} | |
if user.Password != expected { | |
t.Errorf("password not saved") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment