diff options
Diffstat (limited to 'api4')
-rw-r--r-- | api4/apitestlib.go | 9 | ||||
-rw-r--r-- | api4/brand.go | 1 | ||||
-rw-r--r-- | api4/channel.go | 1 | ||||
-rw-r--r-- | api4/channel_test.go | 2 | ||||
-rw-r--r-- | api4/command.go | 1 | ||||
-rw-r--r-- | api4/command_test.go | 1 | ||||
-rw-r--r-- | api4/post.go | 1 | ||||
-rw-r--r-- | api4/post_test.go | 1 | ||||
-rw-r--r-- | api4/team.go | 1 | ||||
-rw-r--r-- | api4/team_test.go | 2 | ||||
-rw-r--r-- | api4/user_test.go | 1 |
11 files changed, 21 insertions, 0 deletions
diff --git a/api4/apitestlib.go b/api4/apitestlib.go index 749053271..863237367 100644 --- a/api4/apitestlib.go +++ b/api4/apitestlib.go @@ -442,6 +442,15 @@ func CheckNoError(t *testing.T, resp *model.Response) { } } +func CheckCreatedStatus(t *testing.T, resp *model.Response) { + if resp.StatusCode != http.StatusCreated { + debug.PrintStack() + t.Log("actual: " + strconv.Itoa(resp.StatusCode)) + t.Log("expected: " + strconv.Itoa(http.StatusCreated)) + t.Fatal("wrong status code") + } +} + func CheckForbiddenStatus(t *testing.T, resp *model.Response) { if resp.Error == nil { debug.PrintStack() diff --git a/api4/brand.go b/api4/brand.go index 00e6bbbff..f9a301acf 100644 --- a/api4/brand.go +++ b/api4/brand.go @@ -66,5 +66,6 @@ func uploadBrandImage(c *Context, w http.ResponseWriter, r *http.Request) { c.LogAudit("") + w.WriteHeader(http.StatusCreated) ReturnStatusOK(w) } diff --git a/api4/channel.go b/api4/channel.go index b7f9508d6..c9a6ac6c5 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -738,6 +738,7 @@ func addChannelMember(c *Context, w http.ResponseWriter, r *http.Request) { return } else { c.LogAudit("name=" + channel.Name + " user_id=" + cm.UserId) + w.WriteHeader(http.StatusCreated) w.Write([]byte(cm.ToJson())) } } diff --git a/api4/channel_test.go b/api4/channel_test.go index 1875f2c44..1d8053a0a 100644 --- a/api4/channel_test.go +++ b/api4/channel_test.go @@ -27,6 +27,7 @@ func TestCreateChannel(t *testing.T) { rchannel, resp := Client.CreateChannel(channel) CheckNoError(t, resp) + CheckCreatedStatus(t, resp) if rchannel.Name != channel.Name { t.Fatal("names did not match") @@ -1501,6 +1502,7 @@ func TestAddChannelMember(t *testing.T) { cm, resp := Client.AddChannelMember(publicChannel.Id, user2.Id) CheckNoError(t, resp) + CheckCreatedStatus(t, resp) if cm.ChannelId != publicChannel.Id { t.Fatal("should have returned exact channel") diff --git a/api4/command.go b/api4/command.go index 123be1932..64766ef3c 100644 --- a/api4/command.go +++ b/api4/command.go @@ -41,5 +41,6 @@ func createCommand(c *Context, w http.ResponseWriter, r *http.Request) { } c.LogAudit("success") + w.WriteHeader(http.StatusCreated) w.Write([]byte(rcmd.ToJson())) } diff --git a/api4/command_test.go b/api4/command_test.go index 34396808f..aa3ad37b6 100644 --- a/api4/command_test.go +++ b/api4/command_test.go @@ -34,6 +34,7 @@ func TestCreateCommand(t *testing.T) { createdCmd, resp := th.SystemAdminClient.CreateCommand(newCmd) CheckNoError(t, resp) + CheckCreatedStatus(t, resp) if createdCmd.CreatorId != th.SystemAdminUser.Id { t.Fatal("user ids didn't match") } diff --git a/api4/post.go b/api4/post.go index af5fc8cfa..9c671ec21 100644 --- a/api4/post.go +++ b/api4/post.go @@ -52,6 +52,7 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) { return } + w.WriteHeader(http.StatusCreated) w.Write([]byte(rp.ToJson())) } diff --git a/api4/post_test.go b/api4/post_test.go index 8f954efaa..bf896f081 100644 --- a/api4/post_test.go +++ b/api4/post_test.go @@ -23,6 +23,7 @@ func TestCreatePost(t *testing.T) { post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"} rpost, resp := Client.CreatePost(post) CheckNoError(t, resp) + CheckCreatedStatus(t, resp) if rpost.Message != post.Message { t.Fatal("message didn't match") diff --git a/api4/team.go b/api4/team.go index 489265251..4bca56994 100644 --- a/api4/team.go +++ b/api4/team.go @@ -336,6 +336,7 @@ func addTeamMember(c *Context, w http.ResponseWriter, r *http.Request) { return } + w.WriteHeader(http.StatusCreated) w.Write([]byte(member.ToJson())) } diff --git a/api4/team_test.go b/api4/team_test.go index 40f5ec778..a38acf2e6 100644 --- a/api4/team_test.go +++ b/api4/team_test.go @@ -22,6 +22,7 @@ func TestCreateTeam(t *testing.T) { team := &model.Team{Name: GenerateTestUsername(), DisplayName: "Some Team", Type: model.TEAM_OPEN} rteam, resp := Client.CreateTeam(team) CheckNoError(t, resp) + CheckCreatedStatus(t, resp) if rteam.Name != team.Name { t.Fatal("names did not match") @@ -635,6 +636,7 @@ func TestAddTeamMember(t *testing.T) { th.LoginBasic() tm, resp = Client.AddTeamMember(team.Id, otherUser.Id, "", "", "") CheckNoError(t, resp) + CheckCreatedStatus(t, resp) // Check all the returned data. if tm == nil { diff --git a/api4/user_test.go b/api4/user_test.go index 21b240957..7653601e0 100644 --- a/api4/user_test.go +++ b/api4/user_test.go @@ -24,6 +24,7 @@ func TestCreateUser(t *testing.T) { ruser, resp := Client.CreateUser(&user) CheckNoError(t, resp) + CheckCreatedStatus(t, resp) Client.Login(user.Email, user.Password) |