2019-04-22 10:58:24 -05:00
|
|
|
package setting
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2019-05-13 01:45:54 -05:00
|
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
2019-04-22 10:58:24 -05:00
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
)
|
|
|
|
|
|
|
|
type testLogger struct {
|
|
|
|
log.Logger
|
|
|
|
warnCalled bool
|
|
|
|
warnMessage string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stub *testLogger) Warn(testMessage string, ctx ...interface{}) {
|
|
|
|
stub.warnCalled = true
|
|
|
|
stub.warnMessage = testMessage
|
|
|
|
}
|
|
|
|
func TestSessionSettings(t *testing.T) {
|
|
|
|
Convey("session config", t, func() {
|
|
|
|
skipStaticRootValidation = true
|
|
|
|
|
|
|
|
Convey("Reading session should log error ", func() {
|
|
|
|
var (
|
|
|
|
cfg = NewCfg()
|
|
|
|
homePath = "../../"
|
|
|
|
)
|
|
|
|
|
|
|
|
stub := &testLogger{}
|
|
|
|
cfg.Logger = stub
|
|
|
|
|
2019-10-22 09:17:49 -05:00
|
|
|
err := cfg.Load(&CommandLineArgs{
|
2019-04-22 10:58:24 -05:00
|
|
|
HomePath: homePath,
|
|
|
|
Config: filepath.Join(homePath, "pkg/setting/testdata/session.ini"),
|
|
|
|
})
|
2019-10-22 09:17:49 -05:00
|
|
|
So(err, ShouldBeNil)
|
2019-04-22 10:58:24 -05:00
|
|
|
|
|
|
|
So(stub.warnCalled, ShouldEqual, true)
|
|
|
|
So(len(stub.warnMessage), ShouldBeGreaterThan, 0)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|