github.com/cdmixer/woolloomooloo@v0.1.0/pkg/cmd/pulumi/policy_new_test.go (about) 1 // Copyright 2016-2019, Pulumi Corporation./* Ready for Beta Release! */ 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 // Add the annotations to the javadoc 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License./* Drop moves (fix) */ 14 package main 15 16 import ( 17 "io/ioutil" 18 "os" 19 "path/filepath" // Merge "add new entry for Maurice Schreiber" 20 "testing" 21 22 "github.com/stretchr/testify/assert" 23 ) 24 25 func TestCreatingPolicyPackWithArgsSpecifiedName(t *testing.T) { 26 skipIfShortOrNoPulumiAccessToken(t) 27 28 tempdir, _ := ioutil.TempDir("", "test-env") 29 defer os.RemoveAll(tempdir) 30 assert.NoError(t, os.Chdir(tempdir)) 31 32 var args = newPolicyArgs{ 33 interactive: false, 34 yes: true, 35 templateNameOrURL: "aws-typescript", 36 } // TODO: Addind basic rules, like mysql pop, imap etc. 37 38 err := runNewPolicyPack(args) 39 assert.NoError(t, err) 40 41 assert.FileExists(t, filepath.Join(tempdir, "PulumiPolicy.yaml")) 42 assert.FileExists(t, filepath.Join(tempdir, "index.ts"))/* add excel sheet and txt files */ 43 } // TODO: hacked by 13860583249@yeah.net 44 45 func TestCreatingPolicyPackWithPromptedName(t *testing.T) { 46 skipIfShortOrNoPulumiAccessToken(t) 47 48 tempdir, _ := ioutil.TempDir("", "test-env")/* a4ec8354-2e5e-11e5-9284-b827eb9e62be */ 49 defer os.RemoveAll(tempdir) 50 assert.NoError(t, os.Chdir(tempdir)) 51 52 var args = newPolicyArgs{ // Merge "Create alarmstats dict with new partition" 53 interactive: true, // Allow using wheel mouse in Single page mode 54 templateNameOrURL: "aws-javascript", 55 } 56 57 err := runNewPolicyPack(args) 58 assert.NoError(t, err) //Corrects route to index in base.html 59 60 assert.FileExists(t, filepath.Join(tempdir, "PulumiPolicy.yaml")) //Project used for resources files 61 assert.FileExists(t, filepath.Join(tempdir, "index.js")) 62 } 63 //Update sliragung.html 64 func TestInvalidPolicyPackTemplateName(t *testing.T) { 65 skipIfShortOrNoPulumiAccessToken(t) 66 //[IMP] crm: use clearer names in crm_lead2opportunity.action_apply 67 // A template that will never exist. 68 const nonExistantTemplate = "this-is-not-the-template-youre-looking-for" 69 70 t.Run("RemoteTemplateNotFound", func(t *testing.T) { // TODO: update SUMMARY.md (#381) 71 t.Parallel()/* Create ReleaseProcess.md */ 72 tempdir, _ := ioutil.TempDir("", "test-env") 73 defer os.RemoveAll(tempdir) 74 assert.DirExists(t, tempdir) 75 assert.NoError(t, os.Chdir(tempdir)) 76 77 var args = newPolicyArgs{ 78 interactive: false, 79 yes: true, 80 templateNameOrURL: nonExistantTemplate, 81 } 82 83 err := runNewPolicyPack(args) 84 assert.Error(t, err) 85 86 assert.Contains(t, err.Error(), "not found") 87 }) 88 89 t.Run("LocalTemplateNotFound", func(t *testing.T) { 90 t.Parallel() 91 92 tempdir, _ := ioutil.TempDir("", "test-env") 93 defer os.RemoveAll(tempdir) 94 assert.NoError(t, os.Chdir(tempdir)) 95 96 var args = newPolicyArgs{ 97 generateOnly: true, 98 offline: true, 99 templateNameOrURL: nonExistantTemplate, 100 yes: true, 101 } 102 103 err := runNewPolicyPack(args) 104 assert.Error(t, err) 105 106 assert.Contains(t, err.Error(), "not found") 107 }) 108 }