forked from cristianoliveira/ergo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b3f0bf
commit 6e31cc9
Showing
2 changed files
with
171 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestMain(t *testing.T) { | ||
t.Run("it shows usage", func(tt *testing.T) { | ||
args := []string{"ergo", "-h"} | ||
os.Args = args | ||
|
||
main() | ||
// Output: USAGE | ||
}) | ||
} | ||
|
||
func TestListCommand(t *testing.T) { | ||
t.Run("it is list command", func(tt *testing.T) { | ||
args := []string{"ergo", "list"} | ||
os.Args = args | ||
|
||
result := command() | ||
if result == nil { | ||
t.Errorf("Expected result to not be nil") | ||
} | ||
|
||
result() | ||
}) | ||
} | ||
|
||
func TestListNamesCommand(t *testing.T) { | ||
t.Run("it is list-names command", func(tt *testing.T) { | ||
args := []string{"ergo", "list-names"} | ||
os.Args = args | ||
|
||
result := command() | ||
if result == nil { | ||
t.Errorf("Expected result to not be nil") | ||
} | ||
|
||
result() | ||
}) | ||
} | ||
|
||
func TestSetupCommand(t *testing.T) { | ||
t.Run("it shows usage", func(tt *testing.T) { | ||
args := []string{"ergo", "setup"} | ||
os.Args = args | ||
|
||
result := command() | ||
if result != nil { | ||
t.Errorf("Expected result to be nil") | ||
} | ||
}) | ||
|
||
t.Run("it is setup command", func(tt *testing.T) { | ||
args := []string{"ergo", "setup", "osx"} | ||
os.Args = args | ||
|
||
result := command() | ||
if result == nil { | ||
t.Errorf("Expected result not to be nil") | ||
} | ||
}) | ||
} | ||
|
||
func TestUrlCommand(t *testing.T) { | ||
t.Run("it shows usage", func(tt *testing.T) { | ||
args := []string{"ergo", "url"} | ||
os.Args = args | ||
|
||
result := command() | ||
if result != nil { | ||
t.Errorf("Expected result to be nil") | ||
} | ||
}) | ||
|
||
t.Run("it is url command", func(tt *testing.T) { | ||
args := []string{"ergo", "url", "foo"} | ||
os.Args = args | ||
|
||
result := command() | ||
if result == nil { | ||
t.Errorf("Expected result not to be nil") | ||
} | ||
|
||
result() | ||
}) | ||
} | ||
|
||
func TestRunCommand(t *testing.T) { | ||
t.Run("it is url command", func(tt *testing.T) { | ||
args := []string{"ergo", "run"} | ||
os.Args = args | ||
|
||
result := command() | ||
if result == nil { | ||
t.Errorf("Expected result not to be nil") | ||
} | ||
}) | ||
} | ||
|
||
func TestAddCommand(t *testing.T) { | ||
t.Run("it shows usage", func(tt *testing.T) { | ||
args := []string{"ergo", "add"} | ||
os.Args = args | ||
|
||
result := command() | ||
if result != nil { | ||
t.Errorf("Expected result to be nil") | ||
} | ||
}) | ||
|
||
t.Run("it is url command", func(tt *testing.T) { | ||
args := []string{"ergo", "add", "foo", "bar"} | ||
os.Args = args | ||
|
||
result := command() | ||
if result == nil { | ||
t.Errorf("Expected result not to be nil") | ||
} | ||
|
||
result() | ||
}) | ||
} |