mirror of
https://github.com/grafana/grafana.git
synced 2026-08-26 21:37:31 -05:00
Chore: Make Cfg field private in SQLStore (#85593)
* make cfg private in sqlstore * fix db init in tests * fix case * fix folder test init * fix imports * make another Cfg private * remove another Cfg * remove unused variable * use store cfg, it has side-effects * fix mutated cfg in tests
This commit is contained in:
@@ -20,7 +20,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
func TestIntegrationIsUniqueConstraintViolation(t *testing.T) {
|
||||
store := InitTestDB(t)
|
||||
store, _ := InitTestDB(t)
|
||||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
@@ -32,12 +32,12 @@ func TestIntegrationIsUniqueConstraintViolation(t *testing.T) {
|
||||
// Attempt to insert org with provided ID (primary key) twice
|
||||
now := time.Now()
|
||||
org := org.Org{Name: "test org primary key violation", Created: now, Updated: now, ID: 42}
|
||||
err := sess.InsertId(&org, store.Dialect)
|
||||
err := sess.InsertId(&org, store.dialect)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Provide a different name to avoid unique constraint violation
|
||||
org.Name = "test org 2"
|
||||
return sess.InsertId(&org, store.Dialect)
|
||||
return sess.InsertId(&org, store.dialect)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -46,12 +46,12 @@ func TestIntegrationIsUniqueConstraintViolation(t *testing.T) {
|
||||
// Attempt to insert org with reserved name
|
||||
now := time.Now()
|
||||
org := org.Org{Name: "test org unique constrain violation", Created: now, Updated: now, ID: 43}
|
||||
err := sess.InsertId(&org, store.Dialect)
|
||||
err := sess.InsertId(&org, store.dialect)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Provide a different ID to avoid primary key violation
|
||||
org.ID = 44
|
||||
return sess.InsertId(&org, store.Dialect)
|
||||
return sess.InsertId(&org, store.dialect)
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func TestIntegrationIsUniqueConstraintViolation(t *testing.T) {
|
||||
return tc.f(t, sess)
|
||||
})
|
||||
require.Error(t, err)
|
||||
assert.True(t, store.Dialect.IsUniqueConstraintViolation(err))
|
||||
assert.True(t, store.dialect.IsUniqueConstraintViolation(err))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user