summaryrefslogtreecommitdiffstats
path: root/store/storetest/channel_store.go
diff options
context:
space:
mode:
authorChris Duarte <csduarte@users.noreply.github.com>2018-06-26 10:47:39 -0700
committerHarrison Healey <harrisonmhealey@gmail.com>2018-06-26 13:47:39 -0400
commit41d2a9f4352b9ee32bfa77da9ffed03b302d1314 (patch)
tree999d022bc771926ad54d8660cc5912b240cdd956 /store/storetest/channel_store.go
parent3e9fe291f155e711bc2371f5dd57d1d15960bb1d (diff)
downloadchat-41d2a9f4352b9ee32bfa77da9ffed03b302d1314.tar.gz
chat-41d2a9f4352b9ee32bfa77da9ffed03b302d1314.tar.bz2
chat-41d2a9f4352b9ee32bfa77da9ffed03b302d1314.zip
Add Purpose as a searchable field (#8067)
* Add Purpose as a searchable field * Add New Index and Remove old for Channels * Include Purpose in FullTextSearch Clause * Move removeIndex for Channels into upgrade.go
Diffstat (limited to 'store/storetest/channel_store.go')
-rw-r--r--store/storetest/channel_store.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go
index ecec7fab9..b033e9c98 100644
--- a/store/storetest/channel_store.go
+++ b/store/storetest/channel_store.go
@@ -1708,6 +1708,14 @@ func testChannelStoreSearchMore(t *testing.T, ss store.Store) {
o8.Type = model.CHANNEL_PRIVATE
store.Must(ss.Channel().Save(&o8, -1))
+ o9 := model.Channel{}
+ o9.TeamId = o1.TeamId
+ o9.DisplayName = "Channel With Purpose"
+ o9.Purpose = "This can now be searchable!"
+ o9.Name = "with-purpose"
+ o9.Type = model.CHANNEL_OPEN
+ store.Must(ss.Channel().Save(&o9, -1))
+
if result := <-ss.Channel().SearchMore(m1.UserId, o1.TeamId, "ChannelA"); result.Err != nil {
t.Fatal(result.Err)
} else {
@@ -1773,6 +1781,19 @@ func testChannelStoreSearchMore(t *testing.T, ss store.Store) {
}
}
+ if result := <-ss.Channel().SearchMore(m1.UserId, o1.TeamId, "now searchable"); result.Err != nil {
+ t.Fatal(result.Err)
+ } else {
+ channels := result.Data.(*model.ChannelList)
+ if len(*channels) != 1 {
+ t.Fatal("should return 1 channel")
+ }
+
+ if (*channels)[0].Name != o9.Name {
+ t.Fatal("wrong channel returned")
+ }
+ }
+
/*
// Disabling this check as it will fail on PostgreSQL as we have "liberalised" channel matching to deal with
// Full-Text Stemming Limitations.
@@ -1884,6 +1905,14 @@ func testChannelStoreSearchInTeam(t *testing.T, ss store.Store) {
o11.Type = model.CHANNEL_OPEN
store.Must(ss.Channel().Save(&o11, -1))
+ o12 := model.Channel{}
+ o12.TeamId = o1.TeamId
+ o12.DisplayName = "Channel With Purpose"
+ o12.Purpose = "This can now be searchable!"
+ o12.Name = "with-purpose"
+ o12.Type = model.CHANNEL_OPEN
+ store.Must(ss.Channel().Save(&o12, -1))
+
for name, search := range map[string]func(teamId string, term string) store.StoreChannel{
"AutocompleteInTeam": ss.Channel().AutocompleteInTeam,
"SearchInTeam": ss.Channel().SearchInTeam,
@@ -1986,6 +2015,19 @@ func testChannelStoreSearchInTeam(t *testing.T, ss store.Store) {
t.Fatal("wrong channel returned")
}
}
+
+ if result := <-search(o1.TeamId, "now searchable"); result.Err != nil {
+ t.Fatal(result.Err)
+ } else {
+ channels := result.Data.(*model.ChannelList)
+ if len(*channels) != 1 {
+ t.Fatal("should return 1 channel")
+ }
+
+ if (*channels)[0].Name != o12.Name {
+ t.Fatal("wrong channel returned")
+ }
+ }
})
}
}