0
0
mirror of https://github.com/thegeeklab/wp-git-clone.git synced 2024-11-14 19:30:40 +00:00
wp-git-clone/git/submodule_test.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)
})
}
}