github.com/SAP/cloud-mta-build-tool@v1.2.27/cmd/merge_test.go (about) 1 package commands 2 3 import ( 4 "github.com/SAP/cloud-mta/mta" 5 "io/ioutil" 6 "os" 7 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 11 "path/filepath" 12 ) 13 14 var _ = Describe("Merge commands call", func() { 15 AfterEach(func() { 16 Ω(os.RemoveAll(getTestPath("result", "result.yaml"))).Should(Succeed()) 17 }) 18 It("merges with one extension", func() { 19 path := getTestPath("mtaext") 20 mergeCmdSrc = path 21 mergeCmdTrg = getTestPath("result") 22 mergeCmdExtensions = []string{"ext.mtaext"} 23 mergeCmdName = "result.yaml" 24 25 Ω(mergeCmd.RunE(nil, []string{})).Should(Succeed()) 26 27 mtadPath := filepath.Join(mergeCmdTrg, "result.yaml") 28 Ω(mtadPath).Should(BeAnExistingFile()) 29 content, e := ioutil.ReadFile(mtadPath) 30 Ω(e).Should(Succeed()) 31 mtaObj, e := mta.Unmarshal(content) 32 Ω(e).Should(Succeed()) 33 expected, e := mta.Unmarshal([]byte(` 34 ID: mta_demo 35 _schema-version: '2.1' 36 version: 0.0.1 37 38 modules: 39 - name: node 40 type: nodejs 41 path: node 42 provides: 43 - name: node_api 44 properties: 45 url: ${default-url} 46 build-parameters: 47 supported-platforms: [cf] 48 - name: node-js 49 type: nodejs 50 path: node-js 51 provides: 52 - name: node-js_api 53 properties: 54 url: ${default-url} 55 build-parameters: 56 builder: zip 57 supported-platforms: [neo] 58 `)) 59 Ω(e).Should(Succeed()) 60 Ω(mtaObj).Should(Equal(expected)) 61 }) 62 })