Example #1
0
			})
			Context("File is located in same directory as manifest or subdirectory", func() {
				It("makes the file path relative to the manifest directory", func() {
					fakeFilePath = "fake/relative/path/file.tgz"
					result, err := util.AbsolutifyPath(fakeManifestPath, fakeFilePath, realfs)
					Expect(result).To(Equal("/fake/manifest/path/fake/relative/path/file.tgz"))
					Expect(err).ToNot(HaveOccurred())
				})
			})
		})

		Context("File path is absolute", func() {
			Context("file path starts with ~", func() {
				It("expands the file path", func() {
					fakeFilePath = "~/fake/absolute/path/file.tgz"
					currentUserHome, _ := realfs.HomeDir("")

					result, err := util.AbsolutifyPath(fakeManifestPath, fakeFilePath, realfs)
					Expect(result).To(Equal(currentUserHome + "/fake/absolute/path/file.tgz"))
					Expect(err).ToNot(HaveOccurred())
				})
			})

			Context("file path starts with /", func() {
				It("passes the file path it received", func() {
					fakeFilePath = "/fake/absolute/path/file.tgz"
					result, err := util.AbsolutifyPath(fakeManifestPath, fakeFilePath, realfs)
					Expect(result).To(Equal("/fake/absolute/path/file.tgz"))
					Expect(err).ToNot(HaveOccurred())
				})
			})