Skip to content

Commit f8d7884

Browse files
authored
Merge pull request #42 from gbrayhan/codex/fix-undefined--description--field-in-response
Fix undefined medicineID numeric step
2 parents 916555b + 1cead1a commit f8d7884

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Test/integration/steps.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
391403
func 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

Comments
 (0)