#11607 fixed formatting

pull/12274/head
Anton Sergeyev 7 years ago
parent 516839d7b2
commit 2024cf4b56
  1. 2
      conf/sample.ini
  2. 11
      pkg/services/cleanup/cleanup_test.go
  3. 2
      pkg/setting/setting.go

@ -15,7 +15,7 @@
;data = /var/lib/grafana ;data = /var/lib/grafana
# Temporary files in `data` directory older than given duration will be removed # Temporary files in `data` directory older than given duration will be removed
temp_data_lifetime = 24h ;temp_data_lifetime = 24h
# Directory where grafana can store logs # Directory where grafana can store logs
;logs = /var/log/grafana ;logs = /var/log/grafana

@ -1,10 +1,9 @@
package cleanup package cleanup
import ( import (
"testing"
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
. "github.com/smartystreets/goconvey/convey" . "github.com/smartystreets/goconvey/convey"
"testing"
"time" "time"
) )
@ -21,21 +20,21 @@ func TestCleanUpTmpFiles(t *testing.T) {
weekAgo := now.Add(-time.Second * 3600 * 24 * 7) weekAgo := now.Add(-time.Second * 3600 * 24 * 7)
Convey("Should not cleanup recent files", func() { Convey("Should not cleanup recent files", func() {
So(service.shouldCleanupTempFile(secondAgo, now), ShouldBeFalse); So(service.shouldCleanupTempFile(secondAgo, now), ShouldBeFalse)
}) })
Convey("Should cleanup older files", func() { Convey("Should cleanup older files", func() {
So(service.shouldCleanupTempFile(dayAgo, now), ShouldBeTrue); So(service.shouldCleanupTempFile(dayAgo, now), ShouldBeTrue)
}) })
Convey("After increasing temporary files lifetime, older files should be kept", func() { Convey("After increasing temporary files lifetime, older files should be kept", func() {
cfg.TempDataLifetime, _ = time.ParseDuration("1000h") cfg.TempDataLifetime, _ = time.ParseDuration("1000h")
So(service.shouldCleanupTempFile(weekAgo, now), ShouldBeFalse); So(service.shouldCleanupTempFile(weekAgo, now), ShouldBeFalse)
}) })
Convey("If lifetime is 0, files should never be cleaned up", func() { Convey("If lifetime is 0, files should never be cleaned up", func() {
cfg.TempDataLifetime = 0 cfg.TempDataLifetime = 0
So(service.shouldCleanupTempFile(weekAgo, now), ShouldBeFalse); So(service.shouldCleanupTempFile(weekAgo, now), ShouldBeFalse)
}) })
}) })

@ -641,7 +641,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
cfg.ImagesDir = filepath.Join(DataPath, "png") cfg.ImagesDir = filepath.Join(DataPath, "png")
cfg.PhantomDir = filepath.Join(HomePath, "tools/phantomjs") cfg.PhantomDir = filepath.Join(HomePath, "tools/phantomjs")
cfg.TempDataLifetime = iniFile.Section("paths").Key("temp_data_lifetime").MustDuration( cfg.TempDataLifetime = iniFile.Section("paths").Key("temp_data_lifetime").MustDuration(
time.Duration(time.Second*3600*24), time.Duration(time.Second * 3600 * 24),
) )
analytics := iniFile.Section("analytics") analytics := iniFile.Section("analytics")

Loading…
Cancel
Save