summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAnthony HAMON <hamon.anth@gmail.com>2018-09-02 17:18:33 +0200
committerAnthony HAMON <hamon.anth@gmail.com>2018-09-04 06:21:58 +0200
commit06846ef3ae9aed88ff6249cc2fd5bdbe0a55bdc3 (patch)
tree49543283cde0e6e13625c8550d910400861b4a35 /pkg
parent43ad9a81c282022203e45ae3088b93763320bccc (diff)
rename NewApp to Setup
Diffstat (limited to 'pkg')
-rw-r--r--pkg/app/app.go4
-rw-r--r--pkg/commands/git_test.go42
2 files changed, 44 insertions, 2 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go
index fa2415fc3..b03ec5b42 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -65,8 +65,8 @@ func newLogger(config config.AppConfigurer) *logrus.Entry {
})
}
-// NewApp retruns a new applications
-func NewApp(config config.AppConfigurer) (*App, error) {
+// Setup bootstrap a new application
+func Setup(config config.AppConfigurer) (*App, error) {
app := &App{
closers: []io.Closer{},
Config: config,
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go
index ebf4fd43d..64d3828ea 100644
--- a/pkg/commands/git_test.go
+++ b/pkg/commands/git_test.go
@@ -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) {
type scenario struct {
command func(string, ...string) *exec.Cmd