mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
rename NewApp to Setup
This commit is contained in:
parent
43ad9a81c2
commit
06846ef3ae
3 changed files with 45 additions and 3 deletions
2
main.go
2
main.go
|
@ -43,7 +43,7 @@ func main() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
app, err := app.NewApp(appConfig)
|
app, err := app.Setup(appConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Error(err.Error())
|
app.Log.Error(err.Error())
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
@ -65,8 +65,8 @@ func newLogger(config config.AppConfigurer) *logrus.Entry {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewApp retruns a new applications
|
// Setup bootstrap a new application
|
||||||
func NewApp(config config.AppConfigurer) (*App, error) {
|
func Setup(config config.AppConfigurer) (*App, error) {
|
||||||
app := &App{
|
app := &App{
|
||||||
closers: []io.Closer{},
|
closers: []io.Closer{},
|
||||||
Config: config,
|
Config: config,
|
||||||
|
|
|
@ -214,6 +214,48 @@ func TestSetupRepositoryAndWorktree(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewGitCommand(t *testing.T) {
|
||||||
|
actual, err := os.Getwd()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
assert.NoError(t, os.Chdir(actual))
|
||||||
|
}()
|
||||||
|
|
||||||
|
type scenario struct {
|
||||||
|
setup func()
|
||||||
|
test func(*GitCommand, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
scenarios := []scenario{
|
||||||
|
{
|
||||||
|
func() {
|
||||||
|
assert.NoError(t, os.Chdir("/tmp"))
|
||||||
|
},
|
||||||
|
func(gitCmd *GitCommand, err error) {
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Equal(t, ErrGitRepositoryInvalid, err)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
func() {
|
||||||
|
assert.NoError(t, os.RemoveAll("/tmp/lazygit-test"))
|
||||||
|
_, err := gogit.PlainInit("/tmp/lazygit-test", false)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NoError(t, os.Chdir("/tmp/lazygit-test"))
|
||||||
|
},
|
||||||
|
func(gitCmd *GitCommand, err error) {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, s := range scenarios {
|
||||||
|
s.setup()
|
||||||
|
s.test(NewGitCommand(newDummyLog(), newDummyOSCommand(), i18n.NewLocalizer(newDummyLog())))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestGitCommandGetStashEntries(t *testing.T) {
|
func TestGitCommandGetStashEntries(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
command func(string, ...string) *exec.Cmd
|
command func(string, ...string) *exec.Cmd
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue