-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1daad47
commit ab63d2b
Showing
9 changed files
with
137 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package printer | ||
|
||
import ( | ||
"github.com/captainhook-go/captainhook/configuration" | ||
"github.com/captainhook-go/captainhook/events" | ||
"github.com/captainhook-go/captainhook/hooks/app" | ||
"github.com/captainhook-go/captainhook/test" | ||
"testing" | ||
) | ||
|
||
func TestDefaultHookSuccess(t *testing.T) { | ||
io := test.CreateFakeIO() | ||
conf := test.CreateFakeConfig() | ||
repo := test.CreateFakeRepo() | ||
ctx := app.NewContext(io, conf, repo) | ||
hook := &configuration.Hook{} | ||
p := NewDefaultPrinter(io) | ||
|
||
event := events.NewHookStartedEvent(ctx, hook) | ||
|
||
p.HookStarted(event) | ||
|
||
if len(io.Out) < 1 { | ||
t.Errorf("Should have written something") | ||
} | ||
} |
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,21 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/captainhook-go/captainhook/git/types" | ||
"testing" | ||
) | ||
|
||
func TestGet(t *testing.T) { | ||
g := types.NewCmd("config") | ||
g.AddOptions(Get("user.name")) | ||
|
||
if len(g.Options) < 3 { | ||
t.Errorf("Option not added correctly") | ||
} | ||
if g.Options[1] != "--get" { | ||
t.Errorf("Wrong option") | ||
} | ||
if g.Options[2] != "user.name" { | ||
t.Errorf("Wrong option") | ||
} | ||
} |
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,18 @@ | ||
package diff | ||
|
||
import ( | ||
"github.com/captainhook-go/captainhook/git/types" | ||
"testing" | ||
) | ||
|
||
func TestCached(t *testing.T) { | ||
g := types.NewCmd("diff") | ||
g.AddOptions(Cached) | ||
|
||
if len(g.Options) < 2 { | ||
t.Errorf("Option not added correctly") | ||
} | ||
if g.Options[1] != "--cached" { | ||
t.Errorf("Wrong option") | ||
} | ||
} |
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,11 @@ | ||
package difftree | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestNothing(t *testing.T) { | ||
if true == false { | ||
t.Errorf("This is weired") | ||
} | ||
} |
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,18 @@ | ||
package log | ||
|
||
import ( | ||
"github.com/captainhook-go/captainhook/git/types" | ||
"testing" | ||
) | ||
|
||
func TestAbbrevRev(t *testing.T) { | ||
g := types.NewCmd("log") | ||
g.AddOptions(AbbrevCommit) | ||
|
||
if len(g.Options) < 2 { | ||
t.Errorf("Option not added correctly") | ||
} | ||
if g.Options[1] != "--abbrev-commit" { | ||
t.Errorf("Wrong option") | ||
} | ||
} |
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,18 @@ | ||
package revparse | ||
|
||
import ( | ||
"github.com/captainhook-go/captainhook/git/types" | ||
"testing" | ||
) | ||
|
||
func TestAbbrevRev(t *testing.T) { | ||
g := types.NewCmd("revparse") | ||
g.AddOptions(AbbrevRef) | ||
|
||
if len(g.Options) < 2 { | ||
t.Errorf("Option not added correctly") | ||
} | ||
if g.Options[1] != "--abbrev-ref" { | ||
t.Errorf("Wrong option") | ||
} | ||
} |
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,14 @@ | ||
package types | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestSubject(t *testing.T) { | ||
expected := "Foo bar" | ||
m := NewCommitMessage("Foo bar\n\nFiz baz.", "#") | ||
|
||
if m.Subject() != expected { | ||
t.Errorf("Wrong subject, expected '" + expected + "' got '" + m.Subject() + "'") | ||
} | ||
} |
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