Split preference store (#46843)
* Split preference store * Chore: Add tests to pref * Fix preference in wire * Rename and adjust * Add pref service test * Rename methods, add tests * Rename Preferences to Preference, names IDs correctly * Fix lint * Refactor Save * Refactor upsert Add new logic for QueryHistory Rename some fields according to go naming conventions Refactore tests * Roll back ID that breaks tests * Rename Id to ID in UpdatePreferenceQuery * Use preference as a model to modify store * Move pref store fakes to pref test file * Add integration tag for store tests * Adjust test Co-authored-by: yangkb09 <yangkb09@gmail.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package preftest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
pref "github.com/grafana/grafana/pkg/services/preference"
|
||||
)
|
||||
|
||||
type FakePreferenceService struct {
|
||||
ExpectedPreference *pref.Preference
|
||||
ExpectedError error
|
||||
}
|
||||
|
||||
func NewPreferenceServiceFake() *FakePreferenceService {
|
||||
return &FakePreferenceService{}
|
||||
}
|
||||
|
||||
func (f *FakePreferenceService) GetWithDefaults(ctx context.Context, query *pref.GetPreferenceWithDefaultsQuery) (*pref.Preference, error) {
|
||||
return f.ExpectedPreference, f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakePreferenceService) Get(ctx context.Context, query *pref.GetPreferenceQuery) (*pref.Preference, error) {
|
||||
return f.ExpectedPreference, f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakePreferenceService) Save(ctx context.Context, cmd *pref.SavePreferenceCommand) error {
|
||||
return f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakePreferenceService) GetDefaults() *pref.Preference {
|
||||
return f.ExpectedPreference
|
||||
}
|
||||
Reference in New Issue
Block a user