()
| 376 | } |
| 377 | |
| 378 | func (s *UserSuite) Test_UpdateUserByID_UpdatePassword() { |
| 379 | s.db.CreateUser(&model.User{ID: 2, Name: "tom", Pass: password.CreatePassword("old", 5)}) |
| 380 | |
| 381 | s.ctx.Params = gin.Params{{Key: "id", Value: "2"}} |
| 382 | |
| 383 | s.ctx.Request = httptest.NewRequest("POST", "/user/2", strings.NewReader(`{"name": "tom", "pass": "new", "admin": true}`)) |
| 384 | s.ctx.Request.Header.Set("Content-Type", "application/json") |
| 385 | |
| 386 | s.a.UpdateUserByID(s.ctx) |
| 387 | |
| 388 | assert.Equal(s.T(), 200, s.recorder.Code) |
| 389 | user, err := s.db.GetUserByID(2) |
| 390 | assert.NoError(s.T(), err) |
| 391 | assert.NotNil(s.T(), user) |
| 392 | assert.True(s.T(), password.ComparePassword(user.Pass, []byte("new"))) |
| 393 | } |
| 394 | |
| 395 | func (s *UserSuite) Test_UpdatePassword() { |
| 396 | s.db.CreateUser(&model.User{ID: 1, Name: "jmattheis", Pass: password.CreatePassword("old", 5)}) |
nothing calls this directly
no test coverage detected