Chore: Add org methods to org service and store (#55579)
* Add org methods to org service and store * Fix name of fake * Remove unused fake * Add xorm tags and half of a test * Add cmment for clarifying missing part of test * Add some comments about future refactors * Rename test * Add test for update org address
This commit is contained in:
@@ -53,6 +53,47 @@ func TestIntegrationOrgDataAccess(t *testing.T) {
|
||||
err := orgStore.DeleteUserFromAll(context.Background(), 1)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("Update org address", func(t *testing.T) {
|
||||
// make sure ac2 has no org
|
||||
ac2 := &org.Org{ID: 21, Name: "name", Version: 1, Created: time.Now(), Updated: time.Now()}
|
||||
_, err := orgStore.Insert(context.Background(), ac2)
|
||||
require.NoError(t, err)
|
||||
err = orgStore.UpdateAddress(context.Background(), &org.UpdateOrgAddressCommand{
|
||||
OrgID: ac2.ID,
|
||||
Address: org.Address{
|
||||
Address1: "address1",
|
||||
Address2: "address2",
|
||||
City: "city",
|
||||
ZipCode: "zip",
|
||||
State: "state",
|
||||
Country: "country"},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
orga, err := orgStore.Get(context.Background(), ac2.ID)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "address1", orga.Address1)
|
||||
})
|
||||
|
||||
t.Run("Removing org", func(t *testing.T) {
|
||||
// make sure ac2 has no org
|
||||
ac2 := &org.Org{ID: 22, Name: "ac2", Version: 1, Created: time.Now(), Updated: time.Now()}
|
||||
_, err := orgStore.Insert(context.Background(), ac2)
|
||||
require.NoError(t, err)
|
||||
err = orgStore.Delete(context.Background(), &org.DeleteOrgCommand{ID: ac2.ID})
|
||||
require.NoError(t, err)
|
||||
|
||||
// TODO: this part of the test will be added when we move RemoveOrgUser to org store
|
||||
// "Removing user from org should delete user completely if in no other org"
|
||||
// // remove ac2 user from ac1 org
|
||||
// remCmd := models.RemoveOrgUserCommand{OrgId: ac1.OrgID, UserId: ac2.ID, ShouldDeleteOrphanedUser: true}
|
||||
// err = orgStore.RemoveOrgUser(context.Background(), &remCmd)
|
||||
// require.NoError(t, err)
|
||||
// require.True(t, remCmd.UserWasDeleted)
|
||||
|
||||
// err = orgStore.GetSignedInUser(context.Background(), &models.GetSignedInUserQuery{UserId: ac2.ID})
|
||||
// require.Equal(t, err, user.ErrUserNotFound)
|
||||
})
|
||||
}
|
||||
|
||||
func TestIntegrationOrgUserDataAccess(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user