Skip to content

Commit d5dc9aa

Browse files
committed
fix: return 201 Created for CreateVariable API responses
- Change CreateVariable API response status from 204 No Content to 201 Created - Update related integration tests to expect 201 Created instead of 204 No Content Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 0d1d57c commit d5dc9aa

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

routers/api/v1/org/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ func (Action) CreateVariable(ctx *context.APIContext) {
419419
return
420420
}
421421

422-
ctx.Status(http.StatusNoContent)
422+
ctx.Status(http.StatusCreated)
423423
}
424424

425425
// UpdateVariable update an org-level variable

tests/integration/api_repo_variables_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ func TestAPIRepoVariables(t *testing.T) {
3535
},
3636
{
3737
Name: "_",
38-
ExpectedStatus: http.StatusNoContent,
38+
ExpectedStatus: http.StatusCreated,
3939
},
4040
{
4141
Name: "TEST_VAR",
42-
ExpectedStatus: http.StatusNoContent,
42+
ExpectedStatus: http.StatusCreated,
4343
},
4444
{
4545
Name: "test_var",
@@ -81,7 +81,7 @@ func TestAPIRepoVariables(t *testing.T) {
8181
req := NewRequestWithJSON(t, "POST", url, api.CreateVariableOption{
8282
Value: "initial_val",
8383
}).AddTokenAuth(token)
84-
MakeRequest(t, req, http.StatusNoContent)
84+
MakeRequest(t, req, http.StatusCreated)
8585

8686
cases := []struct {
8787
Name string

0 commit comments

Comments
 (0)