(ctx context.Context, groupsToLoad map[string]rulespb.RuleGroupList)
| 230 | } |
| 231 | |
| 232 | func (m *mockRuleStore) LoadRuleGroups(ctx context.Context, groupsToLoad map[string]rulespb.RuleGroupList) (map[string]rulespb.RuleGroupList, error) { |
| 233 | m.mtx.Lock() |
| 234 | defer m.mtx.Unlock() |
| 235 | result := make(map[string]rulespb.RuleGroupList, len(groupsToLoad)) |
| 236 | var err error |
| 237 | |
| 238 | gm := make(map[string]*rulespb.RuleGroupDesc) |
| 239 | for _, gs := range m.rules { |
| 240 | for _, gr := range gs { |
| 241 | user, namespace, name := gr.GetUser(), gr.GetNamespace(), gr.GetName() |
| 242 | key := user + delim + base64.URLEncoding.EncodeToString([]byte(namespace)) + delim + base64.URLEncoding.EncodeToString([]byte(name)) |
| 243 | gm[key] = gr |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | for _, gs := range groupsToLoad { |
| 248 | for _, gr := range gs { |
| 249 | user, namespace, name := gr.GetUser(), gr.GetNamespace(), gr.GetName() |
| 250 | if e, ok := m.errorMap[user]; ok { |
| 251 | err = e |
| 252 | continue |
| 253 | } |
| 254 | key := user + delim + base64.URLEncoding.EncodeToString([]byte(namespace)) + delim + base64.URLEncoding.EncodeToString([]byte(name)) |
| 255 | mgr, ok := gm[key] |
| 256 | if !ok { |
| 257 | return nil, fmt.Errorf("failed to get rule group user %s", gr.GetUser()) |
| 258 | } |
| 259 | *gr = *mgr |
| 260 | result[user] = append(result[user], gr) |
| 261 | } |
| 262 | } |
| 263 | return result, err |
| 264 | } |
| 265 | |
| 266 | func (m *mockRuleStore) GetRuleGroup(_ context.Context, userID string, namespace string, group string) (*rulespb.RuleGroupDesc, error) { |
| 267 | m.mtx.Lock() |
nothing calls this directly
no test coverage detected