コード例 #1
0
ファイル: task_test.go プロジェクト: Gerg/inigo
				Expect(task.Failed).To(BeTrue())
				Expect(task.FailureReason).To(ContainSubstring("exceeded 500ms timeout"))
			})
		})
	})
	Describe("Running a downloaded file", func() {
		var guid string

		BeforeEach(func() {
			guid = helpers.GenerateGuid()

			test_helper.CreateTarGZArchive(filepath.Join(fileServerStaticDir, "announce.tar.gz"), []test_helper.ArchiveFile{
				{
					Name: "announce",
					Body: fmt.Sprintf("#!/bin/sh\n\ncurl %s", inigo_announcement_server.AnnounceURL(guid)),
					Mode: 0755,
				},
			})
		})

		It("downloads the file", func() {
			err := receptorClient.CreateTask(helpers.TaskCreateRequest(
				guid,
				models.Serial(
					&models.DownloadAction{
						From: fmt.Sprintf("http://%s/v1/static/%s", componentMaker.Addresses.FileServer, "announce.tar.gz"),
						To:   ".",
						User: "******",
					},
					&models.RunAction{
コード例 #2
0
	Describe("StreamIn", func() {
		var tarStream io.Reader

		BeforeEach(func() {
			tmpdir, err := ioutil.TempDir("", "some-temp-dir-parent")
			Expect(err).ToNot(HaveOccurred())

			tgzPath := filepath.Join(tmpdir, "some.tgz")

			archiver.CreateTarGZArchive(
				tgzPath,
				[]archiver.ArchiveFile{
					{
						Name: "./some-temp-dir",
						Dir:  true,
					},
					{
						Name: "./some-temp-dir/some-temp-file",
						Body: "some-body",
					},
				},
			)

			tgz, err := os.Open(tgzPath)
			Expect(err).ToNot(HaveOccurred())

			tarStream, err = gzip.NewReader(tgz)
			Expect(err).ToNot(HaveOccurred())
		})

		It("should stream in the files", func() {
コード例 #3
0
				_, err := exec.LookPath("unzip")
				Expect(err).To(HaveOccurred())
			})

			AfterEach(func() {
				os.Setenv("PATH", oldPATH)
			})

			It("extracts the ZIP's files, generating directories, and honoring file permissions and symlinks", extractionTest)
		})
	})

	Context("when the file is a tgz archive", func() {
		BeforeEach(func() {
			test_helper.CreateTarGZArchive(extractionSrc, archiveFiles)
		})

		Context("when 'tar' is on the PATH", func() {
			BeforeEach(func() {
				_, err := exec.LookPath("tar")
				Expect(err).NotTo(HaveOccurred())
			})

			It("extracts the TGZ's files, generating directories, and honoring file permissions and symlinks", extractionTest)
		})

		Context("when 'tar' is not in the PATH", func() {
			var oldPATH string

			BeforeEach(func() {