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

Function TestSearchWorkspace

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

Source from the content-addressed store, hash-verified

20)
21
22func TestSearchWorkspace(t *testing.T) {
23 t.Parallel()
24 testCases := []struct {
25 Name string
26 Query string
27 Expected database.GetWorkspacesParams
28 ExpectedErrorContains string
29 Setup func(t *testing.T, db database.Store)
30 }{
31 {
32 Name: "Empty",
33 Query: "",
34 Expected: database.GetWorkspacesParams{},
35 },
36 {
37 Name: "Owner/Name",
38 Query: "Foo/Bar",
39 Expected: database.GetWorkspacesParams{
40 OwnerUsername: "foo",
41 Name: "bar",
42 },
43 },
44 {
45 Name: "Owner/NameWithSpaces",
46 Query: " Foo/Bar ",
47 Expected: database.GetWorkspacesParams{
48 OwnerUsername: "foo",
49 Name: "bar",
50 },
51 },
52 {
53 Name: "Name",
54 Query: "workspace-name",
55 Expected: database.GetWorkspacesParams{
56 Name: "workspace-name",
57 },
58 },
59 {
60 Name: "Name+Param",
61 Query: "workspace-name TEMPLATE:docker",
62 Expected: database.GetWorkspacesParams{
63 Name: "workspace-name",
64 TemplateName: "docker",
65 },
66 },
67 {
68 Name: "OnlyParams",
69 Query: "name:workspace-name template:docker OWNER:Alice",
70 Expected: database.GetWorkspacesParams{
71 Name: "workspace-name",
72 TemplateName: "docker",
73 OwnerUsername: "alice",
74 },
75 },
76 {
77 Name: "QuotedParam",
78 Query: `name:workspace-name template:"docker template" owner:alice`,
79 Expected: database.GetWorkspacesParams{

Callers

nothing calls this directly

Calls 15

OrganizationFunction · 0.92
UserFunction · 0.92
GroupFunction · 0.92
NewDBFunction · 0.92
WorkspacesFunction · 0.92
WriteStringMethod · 0.80
GetOrganizationByNameMethod · 0.65
ContextMethod · 0.65
RunMethod · 0.65
SetupMethod · 0.65
ContainsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected