コード例 #1
0
ファイル: parser_test.go プロジェクト: Aleabawa/cf-download
package dir_parser_test

import (
	"github.com/ibmjstart/cf-download/cmd_exec/cmd_exec_fake"
	. "github.com/ibmjstart/cf-download/dir_parser"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

//unit tests
var _ = Describe("DirParser", func() {
	var p Parser
	var cmdExec cmd_exec_fake.FakeCmdExec

	BeforeEach(func() {
		cmdExec = cmd_exec_fake.NewCmdExec()
		p = NewParser(cmdExec, "TestApp", "0", false, false)
	})
	Describe("Test getFailedDownloads()", func() {
		It("Should return empty []string because no directory string downloads have failed.", func() {
			fails := p.GetFailedDownloads()
			Ω(len(fails)).To(Equal(0))
		})
	})

	Describe("Test ExecParseDir()", func() {
		It("Should return 8 files and 3 directories", func() {
			cmdExec.SetOutput("Getting files for app smithInTheHouse in org jstart / space evans as [email protected]...\nOK\n\n.npmignore 136B\nLICENSE 1.1K\nREADME.md 5.3K\nReadme_zh-cn.md 28.4K\nbin/ -\ncomponent.json 282B\nindex.js 95B\njade-language.md 20.0K\njade.js 757.2K\njade.md 11.3K\nlib/ -\nnode_modules/ -\npackage.json 2.0K\nruntime.js 5.1K")
			files, directories := p.ExecParseDir("readPath")
			Ω(len(files)).To(Equal(11))
			Ω(files[0]).To(Equal(".npmignore"))
コード例 #2
0
ファイル: download_test.go プロジェクト: Aleabawa/cf-download
import (
	"errors"
	"github.com/ibmjstart/cf-download/cmd_exec/cmd_exec_fake"
	. "github.com/ibmjstart/cf-download/downloader"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"io/ioutil"
	"os"
	"sync"
)

var _ = Describe("Downloader tests", func() {
	var (
		wg               sync.WaitGroup
		d                Downloader
		cmdExec          cmd_exec_fake.FakeCmdExec
		currentDirectory string
	)

	currentDirectory, _ = os.Getwd()
	os.MkdirAll(currentDirectory+"/testFiles/", 0755)

	cmdExec = cmd_exec_fake.NewCmdExec()
	d = NewDownloader(cmdExec, &wg, "appName", "0", "rootWorkingDirectory", false, false)

	// downloadfile also tests the following functions
	// WriteFile(), CheckDownload()
	Describe("Test DownloadFile function", func() {
		Context("download and create a file containing only 'helloWorld'", func() {
			It("create test1.txt", func() {
				writePath := currentDirectory + "/testFiles/test1.txt"