1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-10 04:07:18 +02:00
lazygit/pkg/utils/dummies.go

42 lines
1.0 KiB
Go
Raw Normal View History

package utils
import (
2022-09-13 18:30:08 +02:00
"io"
"github.com/jesseduffield/lazygit/pkg/common"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/sirupsen/logrus"
"github.com/spf13/afero"
)
// NewDummyLog creates a new dummy Log for testing
func NewDummyLog() *logrus.Entry {
log := logrus.New()
2022-09-13 12:11:03 +02:00
log.Out = io.Discard
return log.WithField("test", "test")
}
func NewDummyCommon() *common.Common {
tr := i18n.EnglishTranslationSet()
return &common.Common{
Log: NewDummyLog(),
Tr: &tr,
2021-12-29 03:03:35 +02:00
UserConfig: config.GetDefaultConfig(),
Fs: afero.NewOsFs(),
}
}
2022-01-02 01:34:33 +02:00
2023-08-28 12:24:58 +02:00
func NewDummyCommonWithUserConfigAndAppState(userConfig *config.UserConfig, appState *config.AppState) *common.Common {
2022-01-08 04:22:29 +02:00
tr := i18n.EnglishTranslationSet()
return &common.Common{
Log: NewDummyLog(),
Tr: &tr,
UserConfig: userConfig,
2023-08-28 12:24:58 +02:00
AppState: appState,
// TODO: remove dependency on actual filesystem in tests and switch to using
// in-memory for everything
Fs: afero.NewOsFs(),
2022-01-08 04:22:29 +02:00
}
}