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

Function TestCacheUpdate

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

Source from the content-addressed store, hash-verified

54}
55
56func TestCacheUpdate(t *testing.T) {
57 t.Parallel()
58
59 var (
60 user = database.User{
61 ID: uuid.New(),
62 Username: "bill",
63 }
64 template = database.Template{
65 ID: uuid.New(),
66 Name: "tpl",
67 }
68 workspace = database.Workspace{
69 ID: uuid.New(),
70 OwnerID: user.ID,
71 OwnerUsername: user.Username,
72 TemplateID: template.ID,
73 Name: "xyz",
74 TemplateName: template.Name,
75 }
76 workspaceAsCacheFields = agentapi.CachedWorkspaceFields{}
77 )
78
79 workspaceAsCacheFields.UpdateValues(database.Workspace{
80 ID: workspace.ID,
81 OwnerID: workspace.OwnerID,
82 OwnerUsername: workspace.OwnerUsername,
83 TemplateID: workspace.TemplateID,
84 Name: workspace.Name,
85 TemplateName: workspace.TemplateName,
86 AutostartSchedule: workspace.AutostartSchedule,
87 },
88 )
89
90 cws := agentapi.CachedWorkspaceFields{}
91 cws.UpdateValues(workspace)
92 wsi, ok := workspaceAsCacheFields.AsWorkspaceIdentity()
93 require.True(t, ok)
94 cwsi, ok := cws.AsWorkspaceIdentity()
95 require.True(t, ok)
96 require.True(t, wsi.Equal(cwsi))
97}

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected