diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-02-02 11:46:42 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-02-02 11:46:42 -0500 |
commit | 365514174ef00dcf426b2b5704c3d7adebe926e1 (patch) | |
tree | 41f5544aed1b822ae4e476c9ede496ce740d5048 /store/sql_channel_store.go | |
parent | 60be5c902fe30c978d5b30f265509dc28c451407 (diff) | |
download | chat-365514174ef00dcf426b2b5704c3d7adebe926e1.tar.gz chat-365514174ef00dcf426b2b5704c3d7adebe926e1.tar.bz2 chat-365514174ef00dcf426b2b5704c3d7adebe926e1.zip |
Add tear down to APIv4 tests (#5250)
* Add tear down to APIv4 tests
* Defer tear downs
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r-- | store/sql_channel_store.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index a8474be80..7c4e97bc0 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -410,6 +410,41 @@ func (s SqlChannelStore) PermanentDeleteByTeam(teamId string) StoreChannel { return storeChannel } +func (s SqlChannelStore) PermanentDelete(channelId string) StoreChannel { + storeChannel := make(StoreChannel, 1) + + go func() { + result := StoreResult{} + + if _, err := s.GetMaster().Exec("DELETE FROM Channels WHERE Id = :ChannelId", map[string]interface{}{"ChannelId": channelId}); err != nil { + result.Err = model.NewLocAppError("SqlChannelStore.PermanentDelete", "store.sql_channel.permanent_delete.app_error", nil, "channel_id="+channelId+", "+err.Error()) + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + +func (s SqlChannelStore) PermanentDeleteMembersByChannel(channelId string) StoreChannel { + storeChannel := make(StoreChannel, 1) + + go func() { + result := StoreResult{} + + _, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId}) + if err != nil { + result.Err = model.NewLocAppError("SqlChannelStore.RemoveAllMembersByChannel", "store.sql_channel.remove_member.app_error", nil, "channel_id="+channelId+", "+err.Error()) + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + type channelWithMember struct { model.Channel model.ChannelMember |