(t *testing.T)
| 20 | ) |
| 21 | |
| 22 | func 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{ |
nothing calls this directly
no test coverage detected