@@ -93,9 +93,11 @@ var ApplyCmd = &cobra.Command{
9393 grantPermission , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("grant-permission" )))
9494 userLabel := utils .GetStringParam (cmd .Flag ("user-label" ))
9595 wait , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("wait" )))
96+ runTests , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("run-tests" )))
9697
9798 integrationFolder := path .Join (srcFolder , "src" )
9899 testsFolder := path .Join (folder , "tests" )
100+ testsConfigFolder := path .Join (folder , "test-configs" )
99101 authconfigFolder := path .Join (folder , "authconfigs" )
100102 connectorsFolder := path .Join (folder , "connectors" )
101103 customConnectorsFolder := path .Join (folder , "custom-connectors" )
@@ -145,7 +147,7 @@ var ApplyCmd = &cobra.Command{
145147 }
146148
147149 if err = processIntegration (overridesFile , integrationFolder , testsFolder ,
148- configVarsFolder , testsConfigFolder , pipeline , userLabel , grantPermission ); err != nil {
150+ configVarsFolder , testsConfigFolder , pipeline , userLabel , grantPermission , runTests ); err != nil {
149151 return err
150152 }
151153
@@ -159,11 +161,10 @@ Apply scaffold configuration and run functional tests: ` + GetExample(18),
159161}
160162
161163var serviceAccountName , serviceAccountProject , encryptionKey , pipeline , release , outputGCSPath string
162- var testsConfigFolder string
163164
164165func init () {
165166 var userLabel string
166- grantPermission , createSecret , wait := false , false , false
167+ grantPermission , createSecret , wait , runTests := false , false , false , false
167168
168169 ApplyCmd .Flags ().StringVarP (& folder , "folder" , "f" ,
169170 "" , "Folder containing scaffolding configuration" )
@@ -195,8 +196,8 @@ func init() {
195196 false , "Skip applying authconfigs configuration; default is false" )
196197 ApplyCmd .Flags ().BoolVarP (& useUnderscore , "use-underscore" , "" ,
197198 false , "Use underscore as a file splitter; default is __" )
198- ApplyCmd .Flags ().StringVarP ( & testsConfigFolder , "tests-folder " , "" ,
199- "" , "Path to a folder containing files for test case execution. File names MUST match display names. See ./samples/test-config.json for an example" )
199+ ApplyCmd .Flags ().BoolVarP ( & runTests , "run-tests " , "" ,
200+ false , "Runs unit tests from config files in test-configs folder. See ./samples/test-config.json for an example config " )
200201}
201202
202203func getFilenameWithoutExtension (filname string ) string {
@@ -543,6 +544,7 @@ func processSfdcChannels(sfdcchannelsFolder string) (err error) {
543544
544545func processIntegration (overridesFile string , integrationFolder string , testsFolder string ,
545546 configVarsFolder string , testConfigFolder string , pipeline string , userLabel string , grantPermission bool ,
547+ runTests bool ,
546548) (err error ) {
547549 rJSONFiles := regexp .MustCompile (`(\S*)\.json$` )
548550
@@ -631,7 +633,7 @@ func processIntegration(overridesFile string, integrationFolder string, testsFol
631633 }
632634
633635 // Execute test cases
634- if testConfigFolder != "" {
636+ if runTests {
635637 err = executeAllTestCases (testConfigFolder , getFilenameWithoutExtension (integrationNames [0 ]), version )
636638 if err != nil {
637639 return err
@@ -706,12 +708,12 @@ func processCodeFolders(javascriptFolder string, jsonnetFolder string) (codeMap
706708 return codeMap , nil
707709}
708710
709- func processTestCases (testCasesFolder string , integrationName string , version string ) (err error ) {
711+ func processTestCases (testsFolder string , integrationName string , version string ) (err error ) {
710712 rJSONFiles := regexp .MustCompile (`(\S*)\.json` )
711713
712714 var testCaseFiles []string
713715
714- _ = filepath .Walk (testCasesFolder , func (path string , info os.FileInfo , err error ) error {
716+ _ = filepath .Walk (testsFolder , func (path string , info os.FileInfo , err error ) error {
715717 if err != nil {
716718 return err
717719 }
@@ -726,8 +728,15 @@ func processTestCases(testCasesFolder string, integrationName string, version st
726728 })
727729
728730 if len (testCaseFiles ) > 0 {
731+
732+ // delete any old test cases
733+ err = integrations .DeleteAllTestCases (integrationName , version )
734+ if err != nil {
735+ return err
736+ }
737+
729738 for _ , testCaseFile := range testCaseFiles {
730- testCaseBytes , err := utils .ReadFile (path .Join (testCasesFolder , testCaseFile ))
739+ testCaseBytes , err := utils .ReadFile (path .Join (testsFolder , testCaseFile ))
731740 if err != nil {
732741 return err
733742 }
0 commit comments