| 1 |
package commandscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/command`/ |
| 2 |
|
| 3 |
import ( |
| 4 |
"osscip-go gomod github.com/golang/go/src go1.16 os/" |
| 5 |
"testingscip-go gomod github.com/golang/go/src go1.16 testing/" |
| 6 |
|
| 7 |
"github.com/isacikgoz/gitbatch/internal/gitscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/" |
| 8 |
) |
| 9 |
|
| 10 |
func TestRunscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/command`/TestRun().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) { |
| •11 |
// Test must be run from git repo |
| 12 |
t.Skipscip-go gomod github.com/golang/go/src go1.16 testing/common#Skip().() |
| 13 |
wd, err := osscip-go gomod github.com/golang/go/src go1.16 os/.Getwdscip-go gomod github.com/golang/go/src go1.16 os/Getwd().() |
| 14 |
if err != nil { |
| 15 |
t.Fatalfscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatalf().("Test Failed.") |
| 16 |
} |
| 17 |
var tests = []struct { |
| 18 |
inp1 string |
| 19 |
inp2 string |
| 20 |
inp3 []string |
| 21 |
}{ |
| 22 |
{wd, "git", []string{"status"}}, |
| 23 |
} |
| 24 |
for _, test := range tests { |
| 25 |
if output, err := Runscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/command`/Run().(test.inp1, test.inp2, test.inp3); err != nil || len(output) <= 0 { |
| 26 |
t.Errorfscip-go gomod github.com/golang/go/src go1.16 testing/common#Errorf().("Test Failed. {%s, %s, %s} inputted, output: %s", test.inp1, test.inp2, test.inp3, output) |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
func TestReturnscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/command`/TestReturn().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) { |
| 32 |
wd, err := osscip-go gomod github.com/golang/go/src go1.16 os/.Getwdscip-go gomod github.com/golang/go/src go1.16 os/Getwd().() |
| 33 |
if err != nil { |
| 34 |
t.Fatalfscip-go gomod github.com/golang/go/src go1.16 testing/common#Fatalf().("Test Failed.") |
| 35 |
} |
| 36 |
var tests = []struct { |
| 37 |
inp1 string |
| 38 |
inp2 string |
| 39 |
inp3 []string |
| 40 |
expected int |
| 41 |
}{ |
| 42 |
{wd, "foo", []string{}, -1}, |
| 43 |
} |
| 44 |
for _, test := range tests { |
| 45 |
if output, _ := Returnscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/command`/Return().(test.inp1, test.inp2, test.inp3); output != test.expected { |
| 46 |
t.Errorfscip-go gomod github.com/golang/go/src go1.16 testing/common#Errorf().("Test Failed. {%s, %s, %s} inputted, output: %d, expected : %d", test.inp1, test.inp2, test.inp3, output, test.expected) |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
func TestTrimTrailingNewlinescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/command`/TestTrimTrailingNewline().(t *testingscip-go gomod github.com/golang/go/src go1.16 testing/.Tscip-go gomod github.com/golang/go/src go1.16 testing/T#) { |
| 52 |
var tests = []struct { |
| 53 |
input string |
| 54 |
expected string |
| 55 |
}{ |
| 56 |
{"foo", "foo"}, |
| 57 |
{"foo\n", "foo"}, |
| 58 |
{"foo\r", "foo"}, |
| 59 |
} |
| 60 |
for _, test := range tests { |
| 61 |
if output := trimTrailingNewlinescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/command`/trimTrailingNewline().(test.input); output != test.expected { |
| 62 |
t.Errorfscip-go gomod github.com/golang/go/src go1.16 testing/common#Errorf().("Test Failed. %s inputted, output: %s, expected: %s", test.input, output, test.expected) |
| 63 |
} |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
func testFilescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/command`/testFile().(testRepoDir, name string) (*gitscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/.Filescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/File#, error) { |
| 68 |
_, err := osscip-go gomod github.com/golang/go/src go1.16 os/.Createscip-go gomod github.com/golang/go/src go1.16 os/Create().(testRepoDir + string(osscip-go gomod github.com/golang/go/src go1.16 os/.PathSeparatorscip-go gomod github.com/golang/go/src go1.16 os/PathSeparator.) + name) |
| 69 |
if err != nil { |
| 70 |
return nil, err |
| 71 |
} |
| 72 |
f := &gitscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/.Filescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/File#{ |
| 73 |
Namescip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/File#Name.: name, |
| 74 |
AbsPathscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/File#AbsPath.: testRepoDir + string(osscip-go gomod github.com/golang/go/src go1.16 os/.PathSeparatorscip-go gomod github.com/golang/go/src go1.16 os/PathSeparator.) + name, |
| 75 |
Xscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/File#X.: gitscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/.StatusUntrackedscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/StatusUntracked., |
| 76 |
Yscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/File#Y.: gitscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/.StatusUntrackedscip-go gomod github.com/isacikgoz/gitbatch . `github.com/isacikgoz/gitbatch/internal/git`/StatusUntracked., |
| 77 |
} |
| 78 |
return f, nil |
| 79 |
} |