tests
This commit is contained in:
parent
a208b8abe8
commit
3bf40117cc
|
@ -9,9 +9,6 @@ import (
|
|||
"git.csclub.uwaterloo.ca/public/merlin/logger"
|
||||
)
|
||||
|
||||
// probably move this file
|
||||
var CONFIG_PATH = "config_test.ini"
|
||||
|
||||
func dummyRepoConf(name string, syncType string, frequencyStr string, localDir string, rsyncHost string, rsyncDir string) *config.Repo {
|
||||
doneChan := make(chan config.SyncResult)
|
||||
stopChan := make(chan struct{})
|
||||
|
@ -33,7 +30,7 @@ func dummyRepoConf(name string, syncType string, frequencyStr string, localDir s
|
|||
StateFile: "",
|
||||
RepoLogFile: repoLogFile,
|
||||
Logger: logger,
|
||||
RsyncLogFile: "",
|
||||
RsyncLogFile: "/tmp/log/" + name + "-rsync.log",
|
||||
ZfssyncLogFile: "",
|
||||
DoneChan: doneChan,
|
||||
StopChan: stopChan,
|
||||
|
@ -49,27 +46,40 @@ func dummyRepoConf(name string, syncType string, frequencyStr string, localDir s
|
|||
func TestGetSyncCommand(t *testing.T) {
|
||||
|
||||
config.Conf.DownloadDir = "test_files"
|
||||
config.Conf.IPv4Address = "0.0.0.0"
|
||||
config.Conf.DownloadDir = "/tmp/mirror"
|
||||
|
||||
testData := []struct {
|
||||
repoConf *config.Repo
|
||||
expected []string
|
||||
}{
|
||||
{
|
||||
repoConf: dummyRepoConf("ubuntu", "csc-sync-debian", "bi-hourly", "ubuntu", "archive.ubuntu.com", "ubuntu"),
|
||||
expected: []string{},
|
||||
repoConf: dummyRepoConf("ubuntu-releases", "csc-sync-standard", "bi-hourly", "ubuntu-releases", "rsync.releases.ubuntu.com", "releases"),
|
||||
expected: []string{
|
||||
"nice", "rsync", "-aH", "--no-owner", "--no-group", "--delete-after",
|
||||
"--delay-updates", "--safe-links", "--timeout=3600", "-4", "--address=0.0.0.0",
|
||||
"--exclude", ".~tmp~/", "--quiet", "--stats", "--log-file=/tmp/log/ubuntu-releases-rsync.log",
|
||||
"rsync://rsync.releases.ubuntu.com/releases", "/tmp/mirror/ubuntu-releases",
|
||||
},
|
||||
},
|
||||
{
|
||||
repoConf: dummyRepoConf("raspberrypi", "csc-sync-standard-ipv6", "bi-hourly", "raspberrypi", "apt-repo.raspberrypi.org", "archive"),
|
||||
expected: []string{
|
||||
"nice", "rsync", "-aH", "--no-owner", "--no-group", "--delete-after",
|
||||
"--delay-updates", "--safe-links", "--timeout=3600", "-6", "--address=0.0.0.0",
|
||||
"--exclude", ".~tmp~/", "--quiet", "--stats", "--log-file=/tmp/log/raspberrypi-rsync.log",
|
||||
"apt-repo.raspberrypi.org::archive", "/tmp/mirror/raspberrypi",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// WIP, make test pass for now
|
||||
return
|
||||
|
||||
for _, test := range testData {
|
||||
|
||||
syncCommand := getSyncCommand(test.repoConf)
|
||||
|
||||
// check for correct command output
|
||||
if !reflect.DeepEqual(syncCommand, test.expected) {
|
||||
t.Errorf("Invalid command string for %s repo", test.repoConf.Name)
|
||||
t.Errorf("Invalid command string for %s repo\nRECIEVED:\n%+v\nEXPECTED:\n%+v\n", test.repoConf.Name, syncCommand, test.expected)
|
||||
}
|
||||
|
||||
// check if download dir was created
|
||||
|
|
Loading…
Reference in New Issue