github.com/nimakaviani/cli@v6.37.1-0.20180619223813-e734901a73fa+incompatible/integration/helpers/buildpack.go (about) 1 package helpers 2 3 import ( 4 "fmt" 5 "io/ioutil" 6 "os" 7 "path/filepath" 8 9 . "github.com/onsi/gomega" 10 ) 11 12 func BuildpackWithStack(f func(buildpackArchive string), stackName string) { 13 14 archiveFile, err := ioutil.TempFile("", "buildpack-archive-file-") 15 Expect(err).ToNot(HaveOccurred()) 16 Expect(archiveFile.Close()).ToNot(HaveOccurred()) 17 Expect(os.RemoveAll(archiveFile.Name())).ToNot(HaveOccurred()) 18 19 buildpackZip := archiveFile.Name() + ".zip" 20 21 dir, err := ioutil.TempDir("", "buildpack-dir-") 22 Expect(err).ToNot(HaveOccurred()) 23 24 defer os.Remove(buildpackZip) 25 defer os.RemoveAll(dir) 26 27 path := filepath.Join(dir, "bin") 28 err = os.MkdirAll(path, 0755) 29 Expect(err).ToNot(HaveOccurred()) 30 31 compileFile := filepath.Join(path, "compile") 32 err = ioutil.WriteFile(compileFile, []byte("some-content"), 0666) 33 Expect(err).ToNot(HaveOccurred()) 34 35 manifest := filepath.Join(dir, "manifest.yml") 36 err = ioutil.WriteFile(manifest, []byte(fmt.Sprintf("stack: %s", stackName)), 0666) 37 Expect(err).ToNot(HaveOccurred()) 38 39 err = Zipit(dir, buildpackZip, "") 40 Expect(err).ToNot(HaveOccurred()) 41 42 f(buildpackZip) 43 }