1
1
package telemetry_test
2
2
3
3
import (
4
- "context"
5
4
"encoding/json"
6
5
"net/http"
7
6
"net/http/httptest"
@@ -22,6 +21,7 @@ import (
22
21
"github.com/coder/coder/coderd/database/dbfake"
23
22
"github.com/coder/coder/coderd/database/dbgen"
24
23
"github.com/coder/coder/coderd/telemetry"
24
+ "github.com/coder/coder/testutil"
25
25
)
26
26
27
27
func TestMain (m * testing.M ) {
@@ -37,7 +37,7 @@ func TestTelemetry(t *testing.T) {
37
37
38
38
db := dbfake .New ()
39
39
40
- ctx := context . Background ( )
40
+ ctx := testutil . Context ( t , testutil . WaitMedium )
41
41
_ , _ = dbgen .APIKey (t , db , database.APIKey {})
42
42
_ = dbgen .ParameterSchema (t , db , database.ParameterSchema {
43
43
DefaultSourceScheme : database .ParameterSourceSchemeNone ,
@@ -59,7 +59,18 @@ func TestTelemetry(t *testing.T) {
59
59
SharingLevel : database .AppSharingLevelOwner ,
60
60
Health : database .WorkspaceAppHealthDisabled ,
61
61
})
62
- _ = dbgen .WorkspaceAgent (t , db , database.WorkspaceAgent {})
62
+ wsagent := dbgen .WorkspaceAgent (t , db , database.WorkspaceAgent {
63
+ Subsystem : database .WorkspaceAgentSubsystemEnvbox ,
64
+ })
65
+ // Update the workspace agent to have a valid subsystem.
66
+ err = db .UpdateWorkspaceAgentStartupByID (ctx , database.UpdateWorkspaceAgentStartupByIDParams {
67
+ ID : wsagent .ID ,
68
+ Version : wsagent .Version ,
69
+ ExpandedDirectory : wsagent .ExpandedDirectory ,
70
+ Subsystem : database .WorkspaceAgentSubsystemEnvbox ,
71
+ })
72
+ require .NoError (t , err )
73
+
63
74
_ = dbgen .WorkspaceBuild (t , db , database.WorkspaceBuild {
64
75
Transition : database .WorkspaceTransitionStart ,
65
76
Reason : database .BuildReasonAutostart ,
@@ -88,6 +99,9 @@ func TestTelemetry(t *testing.T) {
88
99
require .Len (t , snapshot .WorkspaceBuilds , 1 )
89
100
require .Len (t , snapshot .WorkspaceResources , 1 )
90
101
require .Len (t , snapshot .WorkspaceAgentStats , 1 )
102
+
103
+ wsa := snapshot .WorkspaceAgents [0 ]
104
+ require .Equal (t , string (database .WorkspaceAgentSubsystemEnvbox ), wsa .Subsystem )
91
105
})
92
106
t .Run ("HashedEmail" , func (t * testing.T ) {
93
107
t .Parallel ()
0 commit comments