2024-05-05 20:14:55 +00:00
|
|
|
package git
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-05-06 19:04:48 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2024-05-05 20:14:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestInit(t *testing.T) {
|
2024-05-06 06:52:25 +00:00
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
repo Repository
|
|
|
|
expected []string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "init repo",
|
|
|
|
repo: Repository{
|
|
|
|
WorkDir: "/path/to/repo",
|
|
|
|
Branch: "main",
|
|
|
|
},
|
|
|
|
expected: []string{gitBin, "init", "-b", "main"},
|
|
|
|
},
|
2024-05-05 20:14:55 +00:00
|
|
|
}
|
|
|
|
|
2024-05-06 06:52:25 +00:00
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2024-05-06 18:29:57 +00:00
|
|
|
cmd := tt.repo.Init()
|
2024-05-06 19:04:48 +00:00
|
|
|
assert.Equal(t, tt.expected, cmd.Cmd.Args)
|
|
|
|
assert.Equal(t, tt.repo.WorkDir, cmd.Cmd.Dir)
|
2024-05-06 06:52:25 +00:00
|
|
|
})
|
|
|
|
}
|
2024-05-05 20:14:55 +00:00
|
|
|
}
|