fix(tests): refactor main code for more test coverage

This commit is contained in:
Łukasz Mierzwa
2020-03-10 17:31:12 +00:00
parent 2f661a7f28
commit 9e7d7ed4d6
4 changed files with 10 additions and 7 deletions

View File

@@ -310,11 +310,6 @@ func mainSetup(errorHandling pflag.ErrorHandling) (*gin.Engine, error) {
log.Infof("Parsed %d ACL rule(s)", len(silenceACLs))
}
if *validateConfig {
log.Info("Configuration is valid")
return nil, nil
}
switch config.Config.Debug {
case true:
gin.SetMode(gin.DebugMode)
@@ -350,6 +345,11 @@ func mainSetup(errorHandling pflag.ErrorHandling) (*gin.Engine, error) {
}
}
if *validateConfig {
log.Info("Configuration is valid")
return nil, nil
}
return router, nil
}

View File

@@ -20,7 +20,7 @@ env ANNOTATIONS_STRIP='strip1 strip2 strip3'
env CUSTOM_CSS='/custom.css'
env CUSTOM_JS='/custom.js'
env DEBUG=true
env DEBUG=false
env FILTERS_DEFAULT='@receiver=by-cluster-service @state=active'
@@ -118,7 +118,7 @@ level=info msg=" - strip3"
level=info msg="custom:"
level=info msg=" css: /custom.css"
level=info msg=" js: /custom.js"
level=info msg="debug: true"
level=info msg="debug: false"
level=info msg="filters:"
level=info msg=" default:"
level=info msg=" - '@receiver=by-cluster-service'"

View File

@@ -429,4 +429,6 @@ level=info msg="[ha1] Configured Alertmanager source at http://localhost:9093 (p
level=info msg="[ha2] Configured Alertmanager source at http://localhost:9094 (proxied: false, readonly: true)"
level=info msg="[local] Configured Alertmanager source at http://localhost:9095 (proxied: true, readonly: false)"
level=info msg="[client-auth] Configured Alertmanager source at https://localhost:9096 (proxied: false, readonly: false)"
level=info msg="[ha1] Setting up proxy endpoints"
level=info msg="[local] Setting up proxy endpoints"
level=info msg="Configuration is valid"

View File

@@ -3,6 +3,7 @@ karma.bin-should-work --log.format=text --log.config=true --config.file=karma.ya
! stdout .
stderr 'msg=" proxy: true"'
stderr 'msg="\[proxied\] Configured Alertmanager source at http://localhost \(proxied: true\, readonly: false\)"'
stderr 'msg="\[proxied\] Setting up proxy endpoints"'
! stderr 'level=error'
-- karma.yaml --