Skip to content

Commit c270749

Browse files
authored
Merge pull request #335 from smocker-dev/feat/post-mocks-returns-session
feat(api): return the target session from POST /mocks
2 parents 1ecdd82 + f93e77c commit c270749

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

server/handlers/admin.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,17 @@ func (a *Admin) AddMocks(c echo.Context) error {
7878
}
7979
}
8080

81+
// Return the target session (id + name) so callers — shell scripts especially — can chain a
82+
// GET /mocks?session=<id> without a separate GET /sessions lookup. Session names are not a
83+
// reliable key (they need not be unique); the opaque id is.
84+
session, err := a.mocksServices.GetSessionByID(sessionID)
85+
if err != nil {
86+
return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
87+
}
88+
8189
return c.JSON(http.StatusOK, echo.Map{
8290
"message": "Mocks registered successfully",
91+
"session": session.Summarize(),
8392
})
8493
}
8594

tests/features/set_mocks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ testcases:
1212
assertions:
1313
- result.statuscode ShouldEqual 200
1414
- result.bodyjson.message ShouldEqual "Mocks registered successfully"
15+
# POST /mocks returns the target session so callers can chain GET /mocks?session=<id>.
16+
- result.bodyjson.session.id ShouldNotBeEmpty
17+
- result.bodyjson.session.name ShouldNotBeEmpty
1518

1619
- type: http
1720
method: GET

0 commit comments

Comments
 (0)