MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestCortex_InitRulerStorage

Function TestCortex_InitRulerStorage

pkg/cortex/modules_test.go:112–164  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

110}
111
112func TestCortex_InitRulerStorage(t *testing.T) {
113 tests := map[string]struct {
114 config *Config
115 expectedInit bool
116 }{
117 "should init the ruler storage with target=ruler": {
118 config: func() *Config {
119 cfg := newDefaultConfig()
120 cfg.Target = []string{"ruler"}
121 cfg.RulerStorage.Backend = "local"
122 cfg.RulerStorage.Local.Directory = os.TempDir()
123 return cfg
124 }(),
125 expectedInit: true,
126 },
127 "should not init the ruler storage on default config with target=all": {
128 config: func() *Config {
129 cfg := newDefaultConfig()
130 cfg.Target = []string{"all"}
131 return cfg
132 }(),
133 expectedInit: false,
134 },
135 "should init the ruler storage on ruler storage config with target=all": {
136 config: func() *Config {
137 cfg := newDefaultConfig()
138 cfg.Target = []string{"all"}
139 cfg.RulerStorage.Backend = "local"
140 cfg.RulerStorage.Local.Directory = os.TempDir()
141 return cfg
142 }(),
143 expectedInit: true,
144 },
145 }
146
147 for testName, testData := range tests {
148 t.Run(testName, func(t *testing.T) {
149 cortex := &Cortex{
150 Server: &server.Server{},
151 Cfg: *testData.config,
152 }
153
154 _, err := cortex.initRulerStorage()
155 require.NoError(t, err)
156
157 if testData.expectedInit {
158 assert.NotNil(t, cortex.RulerStorage)
159 } else {
160 assert.Nil(t, cortex.RulerStorage)
161 }
162 })
163 }
164}
165
166type myPusher struct{}
167

Callers

nothing calls this directly

Calls 3

initRulerStorageMethod · 0.95
newDefaultConfigFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected