func processTestCases()

in internal/cmd/integrations/apply.go [707:746]


func processTestCases(testsFolder string, integrationName string, version string) (err error) {
	rJSONFiles := regexp.MustCompile(`(\S*)\.json`)

	var testCaseFiles []string

	_ = filepath.Walk(testsFolder, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if !info.IsDir() {
			testCaseFile := filepath.Base(path)
			if rJSONFiles.MatchString(testCaseFile) {
				clilog.Info.Printf("Found test case file %s for integration: %s\n", testCaseFile, integrationName)
				testCaseFiles = append(testCaseFiles, testCaseFile)
			}
		}
		return nil
	})

	if len(testCaseFiles) > 0 {

		// delete any old test cases
		err = integrations.DeleteAllTestCases(integrationName, version)
		if err != nil {
			return err
		}

		for _, testCaseFile := range testCaseFiles {
			testCaseBytes, err := utils.ReadFile(path.Join(testsFolder, testCaseFile))
			if err != nil {
				return err
			}
			_, err = integrations.CreateTestCase(integrationName, version, string(testCaseBytes))
			if err != nil {
				return err
			}
		}
	}
	return nil
}