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

Function TestCacheClear

coderd/agentapi/cached_workspace_test.go:13–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestCacheClear(t *testing.T) {
14 t.Parallel()
15
16 var (
17 user = database.User{
18 ID: uuid.New(),
19 Username: "bill",
20 }
21 template = database.Template{
22 ID: uuid.New(),
23 Name: "tpl",
24 }
25 workspace = database.Workspace{
26 ID: uuid.New(),
27 OwnerID: user.ID,
28 OwnerUsername: user.Username,
29 TemplateID: template.ID,
30 Name: "xyz",
31 TemplateName: template.Name,
32 }
33 workspaceAsCacheFields = agentapi.CachedWorkspaceFields{}
34 )
35
36 workspaceAsCacheFields.UpdateValues(database.Workspace{
37 ID: workspace.ID,
38 OwnerID: workspace.OwnerID,
39 OwnerUsername: workspace.OwnerUsername,
40 TemplateID: workspace.TemplateID,
41 Name: workspace.Name,
42 TemplateName: workspace.TemplateName,
43 AutostartSchedule: workspace.AutostartSchedule,
44 },
45 )
46
47 emptyCws := agentapi.CachedWorkspaceFields{}
48 workspaceAsCacheFields.Clear()
49 wsi, ok := workspaceAsCacheFields.AsWorkspaceIdentity()
50 require.False(t, ok)
51 ecwsi, ok := emptyCws.AsWorkspaceIdentity()
52 require.False(t, ok)
53 require.True(t, ecwsi.Equal(wsi))
54}
55
56func TestCacheUpdate(t *testing.T) {
57 t.Parallel()

Callers

nothing calls this directly

Calls 5

AsWorkspaceIdentityMethod · 0.95
UpdateValuesMethod · 0.80
NewMethod · 0.65
ClearMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected