Make sure to return on get post error (#5318)

This commit is contained in:
Joram Wilander
2017-02-07 13:04:21 -08:00
committed by Harrison Healey
parent 96e9faca41
commit 25648dda22
2 changed files with 10 additions and 4 deletions
+8 -2
View File
@@ -189,7 +189,7 @@ func (s SqlPostStore) Get(id string) StoreChannel {
pl := &model.PostList{}
if len(id) == 0 {
result.Data = pl
result.Err = model.NewLocAppError("SqlPostStore.GetPost", "store.sql_post.get.app_error", nil, "id="+id)
storeChannel <- result
close(storeChannel)
return
@@ -199,6 +199,9 @@ func (s SqlPostStore) Get(id string) StoreChannel {
err := s.GetReplica().SelectOne(&post, "SELECT * FROM Posts WHERE Id = :Id AND DeleteAt = 0", map[string]interface{}{"Id": id})
if err != nil {
result.Err = model.NewLocAppError("SqlPostStore.GetPost", "store.sql_post.get.app_error", nil, "id="+id+err.Error())
storeChannel <- result
close(storeChannel)
return
}
pl.AddPost(&post)
@@ -211,7 +214,7 @@ func (s SqlPostStore) Get(id string) StoreChannel {
}
if len(rootId) == 0 {
result.Data = pl
result.Err = model.NewLocAppError("SqlPostStore.GetPost", "store.sql_post.get.app_error", nil, "root_id="+rootId)
storeChannel <- result
close(storeChannel)
return
@@ -221,6 +224,9 @@ func (s SqlPostStore) Get(id string) StoreChannel {
_, err = s.GetReplica().Select(&posts, "SELECT * FROM Posts WHERE (Id = :Id OR RootId = :RootId) AND DeleteAt = 0", map[string]interface{}{"Id": rootId, "RootId": rootId})
if err != nil {
result.Err = model.NewLocAppError("SqlPostStore.GetPost", "store.sql_post.get.app_error", nil, "root_id="+rootId+err.Error())
storeChannel <- result
close(storeChannel)
return
} else {
for _, p := range posts {
pl.AddPost(p)
+2 -2
View File
@@ -62,8 +62,8 @@ func TestPostStoreGet(t *testing.T) {
t.Fatal("Missing id should have failed")
}
if err := (<-store.Post().Get("")).Err; err != nil {
t.Fatal(err)
if err := (<-store.Post().Get("")).Err; err == nil {
t.Fatal("should have failed on blank post id")
}
}