grafana/pkg/setting/setting_session_test.go
Arve Knudsen 78596a6756
Migrate to Wire for dependency injection (#32289)
Fixes #30144

Co-authored-by: dsotirakis <sotirakis.dim@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
Co-authored-by: spinillos <selenepinillos@gmail.com>
Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
2021-08-25 15:11:22 +02:00

48 lines
963 B
Go

package setting
import (
"path/filepath"
"testing"
"github.com/grafana/grafana/pkg/infra/log"
. "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 (stub *testLogger) Info(testMessage string, ctx ...interface{}) {
}
func TestSessionSettings(t *testing.T) {
Convey("session config", t, func() {
skipStaticRootValidation = true
Convey("Reading session should log error ", func() {
cfg := NewCfg()
homePath := "../../"
stub := &testLogger{}
cfg.Logger = stub
err := cfg.Load(CommandLineArgs{
HomePath: homePath,
Config: filepath.Join(homePath, "pkg/setting/testdata/session.ini"),
})
So(err, ShouldBeNil)
So(stub.warnCalled, ShouldEqual, true)
So(len(stub.warnMessage), ShouldBeGreaterThan, 0)
})
})
}