コード例 #1
0
ファイル: download_test.go プロジェクト: Aleabawa/cf-download
	*	The Following test call the download function on a test directory (testFiles) which exists in cf-download/downloader/
	*	The directory will be loaded into the download function and written to a new folder called test-download. The test suite
	*	will verify that the directory was loaded and written correctly. Once everything is verified then the test-download directory
	*	will be deleted as to not interfere with the next test. This not only test the entire download functionality but also the
	*	parsing and all flags.
	 */

	Describe("Test Download() Function", func() {
		Context("download the entire directory (no filter)", func() {
			It("should download and write the files to the testFiles Directory", func() {
				d = NewDownloader(cmdExec, &wg, "appName", "0", "rootWorkingDirectory", false, false)
				readPath := currentDirectory
				writePath := currentDirectory + "/test-download"

				// turn on directory faking
				cmdExec.SetFakeDir(true)
				// make sure to turn it off after test
				defer cmdExec.SetFakeDir(false)

				files := []string{}
				dirs := []string{"/testFiles/"}
				filterList := []string{currentDirectory + "/testFiles/.DS_Store", currentDirectory + "/testFiles/app_content/.DS_Store"}

				wg.Add(1)
				go d.Download(files, dirs, readPath, writePath, filterList)
				wg.Wait()

				// test root structure
				rootInfo, _ := os.Stat(writePath + "/testFiles/")
				Ω(rootInfo.IsDir()).To(BeTrue())