diff options
author | =Corey Hulen <corey@hulen.com> | 2016-01-26 20:32:24 -0500 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2016-01-26 20:32:24 -0500 |
commit | c2bc9454ce5550a180d8ee9fec75db7f3841b1ad (patch) | |
tree | bb56d39a6eb468dc002486723bdb085ca7b20a3b /api/user_test.go | |
parent | 21d51f8c9094f434afed8d23d4790aea28a4c0df (diff) | |
download | chat-c2bc9454ce5550a180d8ee9fec75db7f3841b1ad.tar.gz chat-c2bc9454ce5550a180d8ee9fec75db7f3841b1ad.tar.bz2 chat-c2bc9454ce5550a180d8ee9fec75db7f3841b1ad.zip |
PLT-1586 adding attach device id method
Diffstat (limited to 'api/user_test.go')
-rw-r--r-- | api/user_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/api/user_test.go b/api/user_test.go index 9a172805a..5f85bda0f 100644 --- a/api/user_test.go +++ b/api/user_test.go @@ -734,6 +734,34 @@ func TestUserUpdateRoles(t *testing.T) { } } +func TestUserUpdateDeviceId(t *testing.T) { + Setup() + + team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) + + user := &model.User{TeamId: team.Id, Email: "test@nowhere.com", Nickname: "Corey Hulen", Password: "pwd"} + user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User) + store.Must(Srv.Store.User().VerifyEmail(user.Id)) + + Client.LoginByEmail(team.Name, user.Email, "pwd") + deviceId := model.PUSH_NOTIFY_APPLE + ":1234567890" + + if _, err := Client.AttachDeviceId(deviceId); err != nil { + t.Fatal(err) + } + + if result := <-Srv.Store.Session().GetSessions(user.Id); result.Err != nil { + t.Fatal(result.Err) + } else { + sessions := result.Data.([]*model.Session) + + if sessions[0].DeviceId != deviceId { + t.Fatal("Missing device Id") + } + } +} + func TestUserUpdateActive(t *testing.T) { Setup() |