mirror of
https://github.com/thegeeklab/wp-git-action.git
synced 2024-11-09 17:10:41 +00:00
47 lines
1013 B
Go
47 lines
1013 B
Go
|
package plugin
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/require"
|
||
|
)
|
||
|
|
||
|
func TestSyncDirectories(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
name string
|
||
|
exclude []string
|
||
|
del bool
|
||
|
src string
|
||
|
dest string
|
||
|
want []string
|
||
|
}{
|
||
|
{
|
||
|
name: "exclude .git and other patterns",
|
||
|
exclude: []string{"*.log", "temp/"},
|
||
|
del: false,
|
||
|
src: "/path/to/src",
|
||
|
dest: "/path/to/dest",
|
||
|
want: []string{
|
||
|
"rsync", "-r", "--exclude", ".git", "--exclude", "*.log",
|
||
|
"--exclude", "temp/", ".", "/path/to/dest",
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
name: "delete enabled",
|
||
|
exclude: []string{},
|
||
|
del: true,
|
||
|
src: "/path/to/src",
|
||
|
dest: "/path/to/dest",
|
||
|
want: []string{"rsync", "-r", "--exclude", ".git", "--delete", ".", "/path/to/dest"},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for _, tt := range tests {
|
||
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
cmd := SyncDirectories(tt.exclude, tt.del, tt.src, tt.dest)
|
||
|
require.Equal(t, tt.want, cmd.Cmd.Args)
|
||
|
require.Equal(t, tt.src, cmd.Cmd.Dir)
|
||
|
})
|
||
|
}
|
||
|
}
|