github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/actor/pushaction/read_manifest_test.go (about)

     1  package pushaction_test
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os"
     6  	"path/filepath"
     7  
     8  	. "code.cloudfoundry.org/cli/actor/pushaction"
     9  	"code.cloudfoundry.org/cli/types"
    10  	"code.cloudfoundry.org/cli/util/manifest"
    11  
    12  	"github.com/cloudfoundry/bosh-cli/director/template"
    13  	. "github.com/onsi/ginkgo"
    14  	. "github.com/onsi/gomega"
    15  )
    16  
    17  var _ = Describe("ReadManifest", func() {
    18  	var (
    19  		actor *Actor
    20  
    21  		tmpDir         string
    22  		manifestPath   string
    23  		varsFilesPaths []string
    24  		varsKV         []template.VarKV
    25  
    26  		apps       []manifest.Application
    27  		warnings   Warnings
    28  		executeErr error
    29  	)
    30  
    31  	BeforeEach(func() {
    32  		actor, _, _, _ = getTestPushActor()
    33  
    34  		var err error
    35  		tmpDir, err = ioutil.TempDir("", "read-manifest-test")
    36  		Expect(err).ToNot(HaveOccurred())
    37  		manifestPath = filepath.Join(tmpDir, "manifest.yml")
    38  
    39  		varsFilesPaths = nil
    40  		varsKV = nil
    41  	})
    42  
    43  	AfterEach(func() {
    44  		Expect(os.RemoveAll(tmpDir)).To(Succeed())
    45  	})
    46  
    47  	JustBeforeEach(func() {
    48  		apps, warnings, executeErr = actor.ReadManifest(manifestPath, varsFilesPaths, varsKV)
    49  	})
    50  
    51  	When("provided `buildpack`", func() {
    52  		BeforeEach(func() {
    53  			manifest := []byte(`
    54  ---
    55  applications:
    56    - name: some-app
    57      buildpack: some-buildpack
    58    - name: some-other-app
    59      buildpack: some-other-buildpack
    60  `)
    61  
    62  			Expect(ioutil.WriteFile(manifestPath, manifest, 0666)).To(Succeed())
    63  		})
    64  
    65  		It("sets the buildpack on the app and returns a deprecated field warning", func() {
    66  			Expect(executeErr).ToNot(HaveOccurred())
    67  
    68  			Expect(apps).To(ConsistOf(manifest.Application{
    69  				Name:      "some-app",
    70  				Buildpack: types.FilteredString{Value: "some-buildpack", IsSet: true},
    71  			}, manifest.Application{
    72  				Name:      "some-other-app",
    73  				Buildpack: types.FilteredString{Value: "some-other-buildpack", IsSet: true},
    74  			}))
    75  
    76  			Expect(warnings).To(ConsistOf(`Deprecation warning: Use of 'buildpack' attribute in manifest is deprecated in favor of 'buildpacks'. Please see http://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html#deprecated for alternatives and other app manifest deprecations. This feature will be removed in the future.`))
    77  		})
    78  	})
    79  })