github.com/nimakaviani/cli@v6.37.1-0.20180619223813-e734901a73fa+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/actor/pushaction/pushactionfakes"
    10  	"code.cloudfoundry.org/cli/types"
    11  	"code.cloudfoundry.org/cli/util/manifest"
    12  
    13  	"github.com/cloudfoundry/bosh-cli/director/template"
    14  	. "github.com/onsi/ginkgo"
    15  	. "github.com/onsi/gomega"
    16  )
    17  
    18  var _ = Describe("ReadManifest", func() {
    19  	var (
    20  		actor           *Actor
    21  		fakeV2Actor     *pushactionfakes.FakeV2Actor
    22  		fakeSharedActor *pushactionfakes.FakeSharedActor
    23  
    24  		tmpDir         string
    25  		manifestPath   string
    26  		varsFilesPaths []string
    27  		varsKV         []template.VarKV
    28  
    29  		apps       []manifest.Application
    30  		warnings   Warnings
    31  		executeErr error
    32  	)
    33  
    34  	BeforeEach(func() {
    35  		fakeV2Actor = new(pushactionfakes.FakeV2Actor)
    36  		fakeSharedActor = new(pushactionfakes.FakeSharedActor)
    37  		actor = NewActor(fakeV2Actor, nil, fakeSharedActor)
    38  
    39  		var err error
    40  		tmpDir, err = ioutil.TempDir("", "read-manifest-test")
    41  		Expect(err).ToNot(HaveOccurred())
    42  		manifestPath = filepath.Join(tmpDir, "manifest.yml")
    43  
    44  		varsFilesPaths = nil
    45  		varsKV = nil
    46  	})
    47  
    48  	AfterEach(func() {
    49  		Expect(os.RemoveAll(tmpDir)).To(Succeed())
    50  	})
    51  
    52  	JustBeforeEach(func() {
    53  		apps, warnings, executeErr = actor.ReadManifest(manifestPath, varsFilesPaths, varsKV)
    54  	})
    55  
    56  	Context("when provided `buildpack`", func() {
    57  		BeforeEach(func() {
    58  			manifest := []byte(`
    59  ---
    60  applications:
    61    - name: some-app
    62      buildpack: some-buildpack
    63    - name: some-other-app
    64      buildpack: some-other-buildpack
    65  `)
    66  
    67  			Expect(ioutil.WriteFile(manifestPath, manifest, 0666)).To(Succeed())
    68  		})
    69  
    70  		It("sets the buildpack on the app and returns a deprecated field warning", func() {
    71  			Expect(executeErr).ToNot(HaveOccurred())
    72  
    73  			Expect(apps).To(ConsistOf(manifest.Application{
    74  				Name:      "some-app",
    75  				Buildpack: types.FilteredString{Value: "some-buildpack", IsSet: true},
    76  			}, manifest.Application{
    77  				Name:      "some-other-app",
    78  				Buildpack: types.FilteredString{Value: "some-other-buildpack", IsSet: true},
    79  			}))
    80  
    81  			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.`))
    82  		})
    83  	})
    84  })