You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: inmemory_test.go
    path of file: ./repos/grafana/pkg/services/preference/prefimpl
    
    the code of the file until where you have to start completion: package prefimpl

import (
	"context"
	"fmt"
	"sort"

	pref "github.com/grafana/grafana/pkg/services/preference"
)

// preferenceKey represents the primarily used index to access
// preferences.
//
// Preferences are typically ei
    
func (s *inmemStore) Insert(ctx context.Context, preference *pref.Preference) (int64, error) {
	key := preferenceKey{
		OrgID:  preference.OrgID,
		TeamID: preference.TeamID,
		UserID: preference.UserID,
	}

	var p = *preference
	p.ID = s.nextID
	s.nextID++

	if _, exists := s.preference[key]; exists {
		return 0, fmt.Errorf("conflict in fake, preference for [orgid=%d, userid=%d, teamid=%d] already exists", preference.OrgID, preference.UserID, preference.TeamID)
	}

	s.preference[key] = p
	s.idMap[p.ID] = key
	return p.ID, nil
}