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

Function TestConfig_Validate

pkg/overrides/overrides_test.go:27–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestConfig_Validate(t *testing.T) {
28 t.Parallel()
29 tests := map[string]struct {
30 initConfig func(*runtimeconfig.Config)
31 expected error
32 }{
33 "default config should pass": {
34 initConfig: func(cfg *runtimeconfig.Config) {
35 // Set default values for bucket config
36 flagext.DefaultValues(&cfg.StorageConfig)
37 },
38 expected: nil,
39 },
40 "s3 config should pass": {
41 initConfig: func(cfg *runtimeconfig.Config) {
42 cfg.StorageConfig = bucket.Config{
43 Backend: bucket.S3,
44 S3: s3.Config{
45 AccessKeyID: "test-access-key",
46 SecretAccessKey: flagext.Secret{Value: "test-secret-key"},
47 BucketName: "test-bucket",
48 Endpoint: "localhost:9000",
49 Insecure: true,
50 },
51 }
52 // Set default values before validation
53 flagext.DefaultValues(&cfg.StorageConfig.S3)
54 },
55 expected: nil,
56 },
57 }
58
59 for testName, testData := range tests {
60 t.Run(testName, func(t *testing.T) {
61 t.Parallel()
62 cfg := runtimeconfig.Config{}
63
64 testData.initConfig(&cfg)
65
66 if testData.expected == nil {
67 assert.NoError(t, cfg.StorageConfig.Validate())
68 } else {
69 assert.ErrorIs(t, cfg.StorageConfig.Validate(), testData.expected)
70 }
71 })
72 }
73}
74
75func TestConfig_RegisterFlags(t *testing.T) {
76 cfg := runtimeconfig.Config{}

Callers

nothing calls this directly

Calls 4

DefaultValuesFunction · 0.92
initConfigMethod · 0.80
RunMethod · 0.65
ValidateMethod · 0.45

Tested by

no test coverage detected