Skip to content

Commit

Permalink
Adressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Hinderberger committed Jun 3, 2024
1 parent 3d43bd3 commit 8221c91
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions api_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,14 @@ func (ats *Suite) parseAndRunTest(v any, manifestDir, testFilePath string, k, re
// Get the (optional) number of repititions from the test path spec
isParallelPathSpec := false
parallelRepititions := 1
if isParallelPathSpec {
switch t := v.(type) {
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
}
switch t := v.(type) {
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
}

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

// Parse as template always
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))
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))
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 8221c91

Please sign in to comment.