@@ -388,6 +388,18 @@ func theJSONResponseShouldContainWithNumericValueUserID(field string) error {
388388 return theJSONResponseShouldContainNumeric (field , id )
389389}
390390
391+ func theJSONResponseShouldContainWithNumericValueMedicineID (field string ) error {
392+ idStr , ok := savedVars ["medicineID" ]
393+ if ! ok {
394+ return fmt .Errorf ("medicineID not found in saved variables" )
395+ }
396+ id , err := strconv .Atoi (idStr )
397+ if err != nil {
398+ return fmt .Errorf ("medicineID is not numeric: %v" , err )
399+ }
400+ return theJSONResponseShouldContainNumeric (field , id )
401+ }
402+
391403func iSaveTheJSONResponseKeyAs (key , varName string ) error {
392404 if body == nil {
393405 return fmt .Errorf ("response body is nil" )
@@ -903,6 +915,7 @@ func InitializeScenario(ctx *godog.ScenarioContext) {
903915 ctx .Step (`^the JSON response should contain error message "([^"]*)"$` , theJSONResponseShouldContainErrorMessage )
904916 ctx .Step (`^the JSON response should contain "([^"]*)" with numeric value (\d+)$` , theJSONResponseShouldContainNumeric )
905917 ctx .Step (`^the JSON response should contain "([^"]*)" with numeric value \$\{userID\}$` , theJSONResponseShouldContainWithNumericValueUserID )
918+ ctx .Step (`^the JSON response should contain "([^"]*)" with numeric value \$\{medicineID\}$` , theJSONResponseShouldContainWithNumericValueMedicineID )
906919 ctx .Step (`^the JSON response should contain "([^"]*)" with boolean value (true|false)$` , theJSONResponseShouldContainBoolean )
907920 ctx .Step (`^the JSON response should be an array$` , theJSONResponseShouldBeAnArray )
908921 ctx .Step (`^the JSON response field "([^"]*)" should contain string "([^"]*)"$` , theJSONResponseFieldShouldContainString )
0 commit comments