(t *testing.T)
| 29 | ) |
| 30 | |
| 31 | func TestUpdateStats(t *testing.T) { |
| 32 | t.Parallel() |
| 33 | |
| 34 | var ( |
| 35 | user = database.User{ |
| 36 | ID: uuid.New(), |
| 37 | Username: "bill", |
| 38 | } |
| 39 | template = database.Template{ |
| 40 | ID: uuid.New(), |
| 41 | Name: "tpl", |
| 42 | } |
| 43 | workspace = database.Workspace{ |
| 44 | ID: uuid.New(), |
| 45 | OwnerID: user.ID, |
| 46 | OwnerUsername: user.Username, |
| 47 | TemplateID: template.ID, |
| 48 | Name: "xyz", |
| 49 | TemplateName: template.Name, |
| 50 | } |
| 51 | agent = database.WorkspaceAgent{ |
| 52 | ID: uuid.New(), |
| 53 | Name: "abc", |
| 54 | } |
| 55 | workspaceAsCacheFields = agentapi.CachedWorkspaceFields{} |
| 56 | ) |
| 57 | |
| 58 | workspaceAsCacheFields.UpdateValues(database.Workspace{ |
| 59 | ID: workspace.ID, |
| 60 | OwnerID: workspace.OwnerID, |
| 61 | OwnerUsername: workspace.OwnerUsername, |
| 62 | TemplateID: workspace.TemplateID, |
| 63 | Name: workspace.Name, |
| 64 | TemplateName: workspace.TemplateName, |
| 65 | AutostartSchedule: workspace.AutostartSchedule, |
| 66 | }) |
| 67 | |
| 68 | t.Run("OK", func(t *testing.T) { |
| 69 | t.Parallel() |
| 70 | |
| 71 | var ( |
| 72 | now = dbtime.Now() |
| 73 | dbM = dbmock.NewMockStore(gomock.NewController(t)) |
| 74 | ps = pubsub.NewInMemory() |
| 75 | |
| 76 | templateScheduleStore = schedule.MockTemplateScheduleStore{ |
| 77 | GetFn: func(context.Context, database.Store, uuid.UUID) (schedule.TemplateScheduleOptions, error) { |
| 78 | panic("should not be called") |
| 79 | }, |
| 80 | SetFn: func(context.Context, database.Store, database.Template, schedule.TemplateScheduleOptions) (database.Template, error) { |
| 81 | panic("not implemented") |
| 82 | }, |
| 83 | } |
| 84 | batcher = &workspacestatstest.StatsBatcher{} |
| 85 | updateAgentMetricsFnCalled = false |
| 86 | tickCh = make(chan time.Time) |
| 87 | flushCh = make(chan int, 1) |
| 88 | wut = workspacestats.NewTracker(dbM, |
nothing calls this directly
no test coverage detected