Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #110 from bstasyszyn/109
Browse files Browse the repository at this point in the history
feat: Added step to store uncanonicalized JSON value to variable
  • Loading branch information
bstasyszyn authored Nov 13, 2020
2 parents c96c1cf + f19b706 commit 6d0a121
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion bddtests/common_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ func (d *CommonSteps) valuesEqual(value1, value2 string) error {
}

if value1 == value2 {
logger.Infof("Values are equal [%s]", value1)
logger.Infof("Values are equal [%s]=[%s]", value1, value2)

return nil
}
Expand All @@ -1567,6 +1567,22 @@ func (d *CommonSteps) valuesEqual(value1, value2 string) error {
return errors.Errorf("values [%s] and [%s] are not equal", value1, value2)
}

func (d *CommonSteps) valuesNotEqual(value1, value2 string) error {
if err := ResolveVarsInExpression(&value1, &value2); err != nil {
return err
}

if value1 != value2 {
logger.Infof("Values are not equal [%s]!=[%s]", value1, value2)

return nil
}

logger.Infof("Value1 [%s] equals value 2 [%s]", value1, value2)

return errors.Errorf("values [%s] and [%s] are equal", value1, value2)
}

func (d *CommonSteps) setVariable(varName, value string) error {
if err := ResolveVarsInExpression(&value); err != nil {
return err
Expand Down Expand Up @@ -1881,6 +1897,7 @@ func (d *CommonSteps) RegisterSteps(s *godog.Suite) {
s.Step(`^the response is saved to variable "([^"]*)"$`, d.setVariableFromCCResponse)
s.Step(`^variable "([^"]*)" is assigned the value "([^"]*)"$`, d.setVariable)
s.Step(`^variable "([^"]*)" is assigned the JSON value '([^']*)'$`, d.setJSONVariable)
s.Step(`^variable "([^"]*)" is assigned the uncanonicalized JSON value '([^']*)'$`, d.setVariable)
s.Step(`^the response equals "([^"]*)"$`, d.responseEquals)
s.Step(`^the JSON path "([^"]*)" of the response equals "([^"]*)"$`, d.jsonPathOfCCResponseEquals)
s.Step(`^the JSON path "([^"]*)" of the numeric response equals "([^"]*)"$`, d.jsonPathOfNumericResponseEquals)
Expand All @@ -1903,6 +1920,7 @@ func (d *CommonSteps) RegisterSteps(s *godog.Suite) {
s.Step(`^the base64-encoded value "([^"]*)" is decoded and saved to variable "([^"]*)"$`, d.decodeValueFromBase64)
s.Step(`^the base64-encoded value "([^"]*)" is converted to base64URL-encoding and saved to variable "([^"]*)"$`, d.convertValueToBase64URLEncoding)
s.Step(`^the value "([^"]*)" equals "([^"]*)"$`, d.valuesEqual)
s.Step(`^the value "([^"]*)" does not equal "([^"]*)"$`, d.valuesNotEqual)
s.Step(`^the authorization bearer token for "([^"]*)" requests to path "([^"]*)" is set to "([^"]*)"$`, d.setAuthTokenForPath)
s.Step(`^chaincode "([^"]*)" is installed from path "([^"]*)" to all peers$`, d.lifecycleInstallCCToAllPeers)
s.Step(`^chaincode "([^"]*)", version "([^"]*)", package ID "([^"]*)", sequence (\d+) is approved by orgs "([^"]*)" on the "([^"]*)" channel with endorsement policy "([^"]*)" and collection policy "([^"]*)"$`, d.approveCCByOrg)
Expand Down

0 comments on commit 6d0a121

Please sign in to comment.