mirror of
https://github.com/thegeeklab/wp-git-clone.git
synced 2024-11-27 02:00:36 +00:00
85 lines
1.4 KiB
Go
85 lines
1.4 KiB
Go
package git
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// TestUpdateSubmodules tests if the arguments to `git submodule update`
|
|
// are constructed properly.
|
|
func TestUpdateSubmodules(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
repo *Repository
|
|
want []string
|
|
}{
|
|
{
|
|
name: "full submodule update",
|
|
repo: &Repository{
|
|
SubmodulePartial: false,
|
|
},
|
|
want: []string{
|
|
gitBin,
|
|
"submodule",
|
|
"update",
|
|
"--init",
|
|
"--recursive",
|
|
},
|
|
},
|
|
{
|
|
name: "partial submodule update",
|
|
repo: &Repository{
|
|
SubmodulePartial: true,
|
|
},
|
|
want: []string{
|
|
gitBin,
|
|
"submodule",
|
|
"update",
|
|
"--init",
|
|
"--recursive",
|
|
"--depth=1",
|
|
"--recommend-shallow",
|
|
},
|
|
},
|
|
{
|
|
name: "submodule update with remote",
|
|
repo: &Repository{
|
|
SubmoduleRemote: true,
|
|
},
|
|
want: []string{
|
|
gitBin,
|
|
"submodule",
|
|
"update",
|
|
"--init",
|
|
"--recursive",
|
|
"--remote",
|
|
},
|
|
},
|
|
{
|
|
name: "submodule update with remote and partial",
|
|
repo: &Repository{
|
|
SubmoduleRemote: true,
|
|
SubmodulePartial: true,
|
|
},
|
|
want: []string{
|
|
gitBin,
|
|
"submodule",
|
|
"update",
|
|
"--init",
|
|
"--recursive",
|
|
"--depth=1",
|
|
"--recommend-shallow",
|
|
"--remote",
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
cmd := tt.repo.SubmoduleUpdate()
|
|
assert.Equal(t, tt.want, cmd.Args)
|
|
})
|
|
}
|
|
}
|