Skip to content

Commit

Permalink
Fix for "make apitest" regressions due to backtick fix
Browse files Browse the repository at this point in the history
Contrary to what we've first assumed, the recursion after template
evaluation is currently required for correctly running the datastore
tests.

But since parallelRepititions was incorrectly assumed to be never zero,
the recursive call to parseAndRunTest would never actually run its
tests.

This partially reverts commit f2c7937.
  • Loading branch information
Lucas Hinderberger committed Jun 4, 2024
1 parent f2c7937 commit 056bf86
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions api_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ func (ats *Suite) parseAndRunTest(v any, manifestDir, testFilePath string, k, re
case string:
parallelRepititions, _ = util.GetParallelPathSpec(t)

// FIXME - Shouldn't this be > 1 (also in util.IsParallelPathSpec)?
// If so, the declaration in L.6 can be removed and this can be turned
// into a declaration and moved to after the if block.
isParallelPathSpec = parallelRepititions > 0

if parallelRepititions < 1 {
parallelRepititions = 1
}
}

//Get the Manifest with @ logic
Expand All @@ -253,13 +254,21 @@ func (ats *Suite) parseAndRunTest(v any, manifestDir, testFilePath string, k, re
}

// Parse as template always
testObj, err = loader.Render(testObj, filepath.Join(manifestDir, dir), nil)
if err != nil {
r.SaveToReportLog(err.Error())
logrus.Error(fmt.Errorf("can not render template (%s): %s", testFilePath, err))
requestBytes, lErr := loader.Render(testObj, filepath.Join(manifestDir, dir), nil)
if lErr != nil {
r.SaveToReportLog(lErr.Error())
logrus.Error(fmt.Errorf("can not render template (%s): %s", testFilePath, lErr))
return false
}

// If objects are different, we did have a Go template, recurse one level deep
if string(requestBytes) != string(testObj) {
return ats.parseAndRunTest([]byte(requestBytes), filepath.Join(manifestDir, dir),
testFilePath, k, parallelRepititions, isParallelPathSpec, r, loader)
}

testObj = requestBytes

//Try to directly unmarshal the manifest into testcase array
var testCases []json.RawMessage
err = util.Unmarshal(testObj, &testCases)
Expand Down

0 comments on commit 056bf86

Please sign in to comment.