MCPcopy Index your code
hub / github.com/coder/coder / TestSearchChats

Function TestSearchChats

coderd/searchquery/search_test.go:1219–1536  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1217}
1218
1219func TestSearchChats(t *testing.T) {
1220 t.Parallel()
1221
1222 testCases := []struct {
1223 Name string
1224 Query string
1225 Expected database.GetChatsParams
1226 ExpectedErrorContains string
1227 }{
1228 {
1229 Name: "Empty",
1230 Query: "",
1231 Expected: database.GetChatsParams{
1232 Archived: sql.NullBool{Bool: false, Valid: true},
1233 },
1234 },
1235 {
1236 Name: "ArchivedTrue",
1237 Query: "archived:true",
1238 Expected: database.GetChatsParams{
1239 Archived: sql.NullBool{Bool: true, Valid: true},
1240 },
1241 },
1242 {
1243 // Documents that uppercase boolean values still parse. The Chats
1244 // parser intentionally does not pre-lowercase the query because
1245 // diff_url path segments are case-meaningful, so this guards
1246 // against regressions if the blanket lowercase is ever re-added.
1247 Name: "ArchivedTrueUpperCase",
1248 Query: "archived:TRUE",
1249 Expected: database.GetChatsParams{
1250 Archived: sql.NullBool{Bool: true, Valid: true},
1251 },
1252 },
1253 {
1254 Name: "ArchivedFalse",
1255 Query: "archived:false",
1256 Expected: database.GetChatsParams{
1257 Archived: sql.NullBool{Bool: false, Valid: true},
1258 },
1259 },
1260 {
1261 Name: "HasUnreadTrue",
1262 Query: "has_unread:true",
1263 Expected: database.GetChatsParams{
1264 Archived: sql.NullBool{Bool: false, Valid: true},
1265 HasUnread: sql.NullBool{Bool: true, Valid: true},
1266 },
1267 },
1268 {
1269 Name: "HasUnreadFalse",
1270 Query: "has_unread:false",
1271 Expected: database.GetChatsParams{
1272 Archived: sql.NullBool{Bool: false, Valid: true},
1273 HasUnread: sql.NullBool{Bool: false, Valid: true},
1274 },
1275 },
1276 {

Callers

nothing calls this directly

Calls 7

ChatsFunction · 0.92
WriteStringMethod · 0.80
RunMethod · 0.65
ContainsMethod · 0.45
StringMethod · 0.45
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected