Skip to content

Commit 188b558

Browse files
committed
test app merging
1 parent ec4f48f commit 188b558

4 files changed

+34
-10
lines changed

coderd/insights_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,14 @@ func TestTemplateInsights_Golden(t *testing.T) {
10921092
// endedAt: weekAgo.Add(time.Hour),
10931093
// requests: 1,
10941094
// },
1095+
{
1096+
// Different templates but identical apps, apps will be
1097+
// combined and usage will be summed.
1098+
app: users[0].workspaces[1].apps[0],
1099+
startedAt: weekAgo.AddDate(0, 0, 2),
1100+
endedAt: weekAgo.AddDate(0, 0, 2).Add(6 * time.Hour),
1101+
requests: 1,
1102+
},
10951103
},
10961104
},
10971105
users[0].workspaces[2]: {

coderd/testdata/insights/multiple_users_and_workspaces_week_all_templates.json.golden

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,18 @@
5454
},
5555
{
5656
"template_ids": [
57+
"00000000-0000-0000-0000-000000000001",
5758
"00000000-0000-0000-0000-000000000002"
5859
],
5960
"type": "app",
6061
"display_name": "app1",
6162
"slug": "app1",
6263
"icon": "/icon1.png",
63-
"seconds": 3600
64+
"seconds": 25200
6465
},
6566
{
6667
"template_ids": [
67-
"00000000-0000-0000-0000-000000000002"
68+
"00000000-0000-0000-0000-000000000001"
6869
],
6970
"type": "app",
7071
"display_name": "app3",
@@ -90,7 +91,7 @@
9091
"start_time": "2023-08-16T00:00:00Z",
9192
"end_time": "2023-08-17T00:00:00Z",
9293
"template_ids": [
93-
"00000000-0000-0000-0000-000000000002"
94+
"00000000-0000-0000-0000-000000000001"
9495
],
9596
"interval": "day",
9697
"active_users": 1
@@ -99,6 +100,7 @@
99100
"start_time": "2023-08-17T00:00:00Z",
100101
"end_time": "2023-08-18T00:00:00Z",
101102
"template_ids": [
103+
"00000000-0000-0000-0000-000000000001",
102104
"00000000-0000-0000-0000-000000000002"
103105
],
104106
"interval": "day",
@@ -129,7 +131,7 @@
129131
"start_time": "2023-08-21T00:00:00Z",
130132
"end_time": "2023-08-22T00:00:00Z",
131133
"template_ids": [
132-
"00000000-0000-0000-0000-000000000002"
134+
"00000000-0000-0000-0000-000000000001"
133135
],
134136
"interval": "day",
135137
"active_users": 1

coderd/testdata/insights/multiple_users_and_workspaces_week_deployment_wide.json.golden

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,18 @@
5454
},
5555
{
5656
"template_ids": [
57+
"00000000-0000-0000-0000-000000000001",
5758
"00000000-0000-0000-0000-000000000002"
5859
],
5960
"type": "app",
6061
"display_name": "app1",
6162
"slug": "app1",
6263
"icon": "/icon1.png",
63-
"seconds": 3600
64+
"seconds": 25200
6465
},
6566
{
6667
"template_ids": [
67-
"00000000-0000-0000-0000-000000000002"
68+
"00000000-0000-0000-0000-000000000001"
6869
],
6970
"type": "app",
7071
"display_name": "app3",
@@ -90,7 +91,7 @@
9091
"start_time": "2023-08-16T00:00:00Z",
9192
"end_time": "2023-08-17T00:00:00Z",
9293
"template_ids": [
93-
"00000000-0000-0000-0000-000000000002"
94+
"00000000-0000-0000-0000-000000000001"
9495
],
9596
"interval": "day",
9697
"active_users": 1
@@ -99,6 +100,7 @@
99100
"start_time": "2023-08-17T00:00:00Z",
100101
"end_time": "2023-08-18T00:00:00Z",
101102
"template_ids": [
103+
"00000000-0000-0000-0000-000000000001",
102104
"00000000-0000-0000-0000-000000000002"
103105
],
104106
"interval": "day",
@@ -129,7 +131,7 @@
129131
"start_time": "2023-08-21T00:00:00Z",
130132
"end_time": "2023-08-22T00:00:00Z",
131133
"template_ids": [
132-
"00000000-0000-0000-0000-000000000002"
134+
"00000000-0000-0000-0000-000000000001"
133135
],
134136
"interval": "day",
135137
"active_users": 1

coderd/testdata/insights/multiple_users_and_workspaces_week_second_template.json.golden

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
"slug": "ssh",
4747
"icon": "/icon/terminal.svg",
4848
"seconds": 3600
49+
},
50+
{
51+
"template_ids": [
52+
"00000000-0000-0000-0000-000000000001"
53+
],
54+
"type": "app",
55+
"display_name": "app1",
56+
"slug": "app1",
57+
"icon": "/icon1.png",
58+
"seconds": 21600
4959
}
5060
],
5161
"parameters_usage": []
@@ -70,9 +80,11 @@
7080
{
7181
"start_time": "2023-08-17T00:00:00Z",
7282
"end_time": "2023-08-18T00:00:00Z",
73-
"template_ids": [],
83+
"template_ids": [
84+
"00000000-0000-0000-0000-000000000001"
85+
],
7486
"interval": "day",
75-
"active_users": 0
87+
"active_users": 1
7688
},
7789
{
7890
"start_time": "2023-08-18T00:00:00Z",

0 commit comments

Comments
 (0)