Skip to content

Commit

Permalink
Merge pull request #393 from oribon/check_for_removed_tests
Browse files Browse the repository at this point in the history
added test removed from test suite case
  • Loading branch information
openshift-merge-robot authored Jan 14, 2021
2 parents 8378ee4 + 7304e50 commit 0a54764
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions cnf-tests/docgen/cmd/fill.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type TestSuite struct {
}

const emptyPlaceHolder = "XXXXXXXX"
const errMissing = "Found tests with no description"
const errRemoved = "Found tests that were removed"

var (
junit string
Expand Down Expand Up @@ -78,21 +80,37 @@ func fill(xmlFile, descriptionsFile string) {

func fillDescriptions(fileName string, tests TestSuite, currentDescriptions map[string]string) error {
missing := false
removed := false
allTests := make(map[string]bool)
for _, t := range tests.Testcase {
if _, ok := currentDescriptions[t.Name]; !ok {
currentDescriptions[t.Name] = emptyPlaceHolder
fmt.Printf("The test %s do not have a valid description\n", t.Name)
fmt.Printf("The test %s does not have a valid description\n", t.Name)
missing = true
}
allTests[t.Name] = true
}
for k := range currentDescriptions {
if _, ok := allTests[k]; !ok {
delete(currentDescriptions, k)
fmt.Printf("The test %s was removed from the test suite\n", k)
removed = true
}
}
jsonData, err := json.MarshalIndent(currentDescriptions, "", " ")
err = ioutil.WriteFile(fileName, jsonData, os.ModePerm)
if err != nil {
return fmt.Errorf("failed to open the descriptions file %v", err)
}

if missing {
return fmt.Errorf("Found tests with no description")
switch {
case missing && removed:
return fmt.Errorf("%s, %s", errMissing, errRemoved)
case missing:
return fmt.Errorf(errMissing)
case removed:
return fmt.Errorf(errRemoved)
default:
return nil
}
return nil
}

0 comments on commit 0a54764

Please sign in to comment.