Commit 5c31f079 by Torkel Ödegaard Committed by GitHub

Settings: Remove unnessary error handling code (#27420)

* Settings: Remove unnecessary error handling code

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 6fabfee0
......@@ -17,12 +17,12 @@ type DateFormatIntervals struct {
func (cfg *Cfg) readDateFormats() {
dateFormats := cfg.Raw.Section("date_formats")
cfg.DateFormats.FullDate, _ = valueAsString(dateFormats, "full_date", "YYYY-MM-DD HH:mm:ss")
cfg.DateFormats.Interval.Second, _ = valueAsString(dateFormats, "interval_second", "HH:mm:ss")
cfg.DateFormats.Interval.Minute, _ = valueAsString(dateFormats, "interval_minute", "HH:mm")
cfg.DateFormats.Interval.Hour, _ = valueAsString(dateFormats, "interval_hour", "MM-DD HH:mm")
cfg.DateFormats.Interval.Day, _ = valueAsString(dateFormats, "interval_day", "YYYY-MM-DD")
cfg.DateFormats.Interval.Month, _ = valueAsString(dateFormats, "interval_month", "YYYY-MM")
cfg.DateFormats.FullDate = valueAsString(dateFormats, "full_date", "YYYY-MM-DD HH:mm:ss")
cfg.DateFormats.Interval.Second = valueAsString(dateFormats, "interval_second", "HH:mm:ss")
cfg.DateFormats.Interval.Minute = valueAsString(dateFormats, "interval_minute", "HH:mm")
cfg.DateFormats.Interval.Hour = valueAsString(dateFormats, "interval_hour", "MM-DD HH:mm")
cfg.DateFormats.Interval.Day = valueAsString(dateFormats, "interval_day", "YYYY-MM-DD")
cfg.DateFormats.Interval.Month = valueAsString(dateFormats, "interval_month", "YYYY-MM")
cfg.DateFormats.Interval.Year = "YYYY"
cfg.DateFormats.UseBrowserLocale = dateFormats.Key("date_format_use_browser_locale").MustBool(false)
}
......@@ -279,14 +279,12 @@ func TestLoadingSettings(t *testing.T) {
So(err, ShouldBeNil)
Convey("If key is found - should return value from ini file", func() {
value, err := valueAsString(iniFile.Section("server"), "alt_url", "")
So(err, ShouldBeNil)
value := valueAsString(iniFile.Section("server"), "alt_url", "")
So(value, ShouldEqual, "https://grafana.com/")
})
Convey("If key is not found - should return default value", func() {
value, err := valueAsString(iniFile.Section("server"), "extra_url", "default_url_val")
So(err, ShouldBeNil)
value := valueAsString(iniFile.Section("server"), "extra_url", "default_url_val")
So(value, ShouldEqual, "default_url_val")
})
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment