Chore: Remove methods from sqlstore (#57545)

* Remove methods from sqlstore

* Remove commented out code

* Remove GetUserById from tests

* Adjust fake for get user profile

* Adjust test

* Adjust go mod files

* Try fix test

* Test adjustment

* Adjust test 2

* Remove commented out code
This commit is contained in:
idafurjes
2022-10-27 11:44:09 +02:00
committed by GitHub
parent 1340c2c358
commit 50fb47dba0
9 changed files with 34 additions and 243 deletions

View File

@@ -468,7 +468,7 @@ func TestIntegrationOrgUserDataAccess(t *testing.T) {
}
// This test will be refactore after the CRUD store refactor
func TestSQLStore_AddOrgUser(t *testing.T) {
func TestIntegrationSQLStore_AddOrgUser(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@@ -533,7 +533,7 @@ func TestSQLStore_AddOrgUser(t *testing.T) {
require.Equal(t, saFound.OrgID, u.OrgID)
}
func TestSQLStore_GetOrgUsers(t *testing.T) {
func TestIntegration_SQLStore_GetOrgUsers(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@@ -639,7 +639,7 @@ func hasWildcardScope(user *user.SignedInUser, action string) bool {
return false
}
func TestSQLStore_GetOrgUsers_PopulatesCorrectly(t *testing.T) {
func TestIntegration_SQLStore_GetOrgUsers_PopulatesCorrectly(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@@ -654,17 +654,19 @@ func TestSQLStore_GetOrgUsers_PopulatesCorrectly(t *testing.T) {
dialect: store.GetDialect(),
cfg: setting.NewCfg(),
}
_, err := store.CreateUser(context.Background(), user.CreateUserCommand{
Login: "Admin",
Email: "admin@localhost",
OrgID: 1,
})
id, err := orgUserStore.Insert(context.Background(),
&org.Org{
ID: 1,
Created: constNow,
Updated: constNow,
})
require.NoError(t, err)
newUser, err := store.CreateUser(context.Background(), user.CreateUserCommand{
Login: "Viewer",
Email: "viewer@localhost",
OrgID: 1,
OrgID: id,
IsDisabled: true,
Name: "Viewer Localhost",
})
@@ -691,7 +693,7 @@ func TestSQLStore_GetOrgUsers_PopulatesCorrectly(t *testing.T) {
actual := result[0]
assert.Equal(t, int64(1), actual.OrgID)
assert.Equal(t, newUser.ID, actual.UserID)
assert.Equal(t, int64(1), actual.UserID)
assert.Equal(t, "viewer@localhost", actual.Email)
assert.Equal(t, "Viewer Localhost", actual.Name)
assert.Equal(t, "Viewer", actual.Login)
@@ -702,7 +704,7 @@ func TestSQLStore_GetOrgUsers_PopulatesCorrectly(t *testing.T) {
assert.Equal(t, true, actual.IsDisabled)
}
func TestSQLStore_SearchOrgUsers(t *testing.T) {
func TestIntegration_SQLStore_SearchOrgUsers(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
@@ -776,7 +778,10 @@ func TestSQLStore_SearchOrgUsers(t *testing.T) {
}
}
func TestSQLStore_RemoveOrgUser(t *testing.T) {
func TestIntegration_SQLStore_RemoveOrgUser(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
store := db.InitTestDB(t)
orgUserStore := sqlStore{
db: store,
@@ -806,12 +811,6 @@ func TestSQLStore_RemoveOrgUser(t *testing.T) {
})
require.NoError(t, err)
// assert the org has been assigned
user := &models.GetUserByIdQuery{Id: 2}
err = store.GetUserById(context.Background(), user)
require.NoError(t, err)
require.Equal(t, user.Result.OrgID, int64(1))
// remove the user org
err = orgUserStore.RemoveOrgUser(context.Background(), &org.RemoveOrgUserCommand{
UserID: 2,
@@ -819,10 +818,4 @@ func TestSQLStore_RemoveOrgUser(t *testing.T) {
ShouldDeleteOrphanedUser: false,
})
require.NoError(t, err)
// assert the org has been removed
user = &models.GetUserByIdQuery{Id: 2}
err = store.GetUserById(context.Background(), user)
require.NoError(t, err)
require.Equal(t, user.Result.OrgID, int64(0))
}