<commit_before>package rsync_test

import (
	"testing"

	"github.com/mlafeldt/chef-runner/rsync"
	"github.com/stretchr/testify/assert"
)

var commandTests = []struct {
	client rsync.Client
	src    []string
	dst    string
	cmd    []string
}{
	{
		rsync.Client{},
		[]string{"a"}, "b",
		[]string{"rsync", "a", "b"},
	},
	{
		rsync.Client{},
		[]string{"a", "b"}, "c",
		[]string{"rsync", "a", "b", "c"},
	},
	{
		rsync.Client{Archive: true},
		[]string{"a"}, "b",
		[]string{"rsync", "--archive", "a", "b"},
	},
	{
		rsync.Client{Delete: true},
		[]string{"a"}, "b",
		[]string{"rsync", "--delete", "a", "b"},
	},
	{
		rsync.Client{Verbose: true},
		[]string{"a"}, "b",
		[]string{"rsync", "--verbose", "a", "b"},
	},
	{
		rsync.Client{Exclude: []string{"x", "y"}},
		[]string{"a"}, "b",
		[]string{"rsync", "--exclude", "x", "--exclude", "y", "a", "b"},
	},
	{
		rsync.Client{Archive: true, Delete: true, Exclude: []string{"x"}},
		[]string{"a"}, "b",
		[]string{"rsync", "--archive", "--delete", "--exclude", "x", "a", "b"},
	},
}

func TestCommand(t *testing.T) {
	for _, test := range commandTests {
		cmd, err := test.client.Command(test.src, test.dst)
		if assert.NoError(t, err) {
			assert.Equal(t, test.cmd, cmd)
		}
	}
}

func TestCopy_MissingSource(t *testing.T) {
	err := rsync.DefaultClient.Copy([]string{}, "a/b")
	assert.EqualError(t, err, "no source given")
}

func TestCopy_MissingDestination(t *testing.T) {
	err := rsync.DefaultClient.Copy([]string{"a"}, "")
	assert.EqualError(t, err, "no destination given")
}
<commit_msg>Consolidate rsync tests<commit_after>package rsync_test

import (
	"testing"

	"github.com/mlafeldt/chef-runner/rsync"
	"github.com/stretchr/testify/assert"
)

var commandTests = []struct {
	client    rsync.Client
	src       []string
	dst       string
	cmd       []string
	errString string
}{
	{
		client: rsync.Client{},
		src:    []string{"a"},
		dst:    "b",
		cmd:    []string{"rsync", "a", "b"},
	},
	{
		client: rsync.Client{},
		src:    []string{"a", "b"},
		dst:    "c",
		cmd:    []string{"rsync", "a", "b", "c"},
	},
	{
		client: rsync.Client{Archive: true},
		src:    []string{"a"},
		dst:    "b",
		cmd:    []string{"rsync", "--archive", "a", "b"},
	},
	{
		client: rsync.Client{Delete: true},
		src:    []string{"a"},
		dst:    "b",
		cmd:    []string{"rsync", "--delete", "a", "b"},
	},
	{
		client: rsync.Client{Verbose: true},
		src:    []string{"a"},
		dst:    "b",
		cmd:    []string{"rsync", "--verbose", "a", "b"},
	},
	{
		client: rsync.Client{Exclude: []string{"x", "y"}},
		src:    []string{"a"},
		dst:    "b",
		cmd:    []string{"rsync", "--exclude", "x", "--exclude", "y", "a", "b"},
	},
	{
		client: rsync.Client{Archive: true, Delete: true, Exclude: []string{"x"}},
		src:    []string{"a"},
		dst:    "b",
		cmd:    []string{"rsync", "--archive", "--delete", "--exclude", "x", "a", "b"},
	},
	{
		client:    rsync.Client{},
		src:       []string{},
		dst:       "b",
		cmd:       nil,
		errString: "no source given",
	},
	{
		client:    rsync.Client{},
		src:       []string{"a"},
		dst:       "",
		cmd:       nil,
		errString: "no destination given",
	},
}

func TestCommand(t *testing.T) {
	for _, test := range commandTests {
		cmd, err := test.client.Command(test.src, test.dst)
		if test.errString == "" {
			assert.NoError(t, err)
		} else {
			assert.EqualError(t, err, test.errString)
		}
		assert.Equal(t, test.cmd, cmd)
	}
}

{'fraction_non_alphanumeric': 0.2507339988256019, 'fraction_numerical': 0.0, 'mean_word_length': 3.296343001261034, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6301583', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1369, 'n_words': 279}