MCPcopy Create free account
hub / github.com/cortexproject/cortex / Test_mapper_MapRulesSpecialCharNamespace

Function Test_mapper_MapRulesSpecialCharNamespace

pkg/ruler/mapper_test.go:345–377  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

343}
344
345func Test_mapper_MapRulesSpecialCharNamespace(t *testing.T) {
346 l := log.NewLogfmtLogger(os.Stdout)
347 l = level.NewFilter(l, level.AllowInfo())
348 setupRuleSets()
349 m := &mapper{
350 Path: "/rules",
351 FS: afero.NewMemMapFs(),
352 logger: l,
353 }
354
355 t.Run("create special characters rulegroup", func(t *testing.T) {
356 updated, files, err := m.MapRules(testUser, specialCharactersRuleSet)
357 require.NoError(t, err)
358 require.True(t, updated)
359 require.Len(t, files, 1)
360 require.Equal(t, specialCharFilePath, files[0])
361
362 exists, err := afero.Exists(m.FS, specialCharFilePath)
363 require.NoError(t, err)
364 require.True(t, exists)
365 })
366
367 t.Run("delete special characters rulegroup", func(t *testing.T) {
368 updated, files, err := m.MapRules(testUser, map[string][]rulefmt.RuleGroup{})
369 require.NoError(t, err)
370 require.True(t, updated)
371 require.Len(t, files, 0)
372
373 exists, err := afero.Exists(m.FS, specialCharFilePath)
374 require.NoError(t, err)
375 require.False(t, exists)
376 })
377}
378
379func TestYamlFormatting(t *testing.T) {
380 l := log.NewLogfmtLogger(os.Stdout)

Callers

nothing calls this directly

Calls 6

MapRulesMethod · 0.95
setupRuleSetsFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65
LenMethod · 0.45
ExistsMethod · 0.45

Tested by

no test coverage detected