@@ -66,6 +66,47 @@ func APIKey(t *testing.T, db database.Store, seed database.APIKey) (key database
66
66
return key , fmt .Sprintf ("%s-%s" , key .ID , secret )
67
67
}
68
68
69
+ func WorkspaceAgent (t * testing.T , db database.Store , orig database.WorkspaceAgent ) database.WorkspaceAgent {
70
+ workspace , err := db .InsertWorkspaceAgent (context .Background (), database.InsertWorkspaceAgentParams {
71
+ ID : takeFirst (orig .ID , uuid .New ()),
72
+ CreatedAt : takeFirst (orig .CreatedAt , time .Now ()),
73
+ UpdatedAt : takeFirst (orig .UpdatedAt , time .Now ()),
74
+ Name : takeFirst (orig .Name , namesgenerator .GetRandomName (1 )),
75
+ ResourceID : takeFirst (orig .ResourceID , uuid .New ()),
76
+ AuthToken : takeFirst (orig .AuthToken , uuid .New ()),
77
+ AuthInstanceID : sql.NullString {
78
+ String : takeFirst (orig .AuthInstanceID .String , "" ),
79
+ Valid : takeFirst (orig .AuthInstanceID .Valid , false ),
80
+ },
81
+ Architecture : takeFirst (orig .Architecture , "amd64" ),
82
+ EnvironmentVariables : pqtype.NullRawMessage {
83
+ RawMessage : takeFirstBytes (orig .EnvironmentVariables .RawMessage , []byte ("{}" )),
84
+ Valid : takeFirst (orig .EnvironmentVariables .Valid , false ),
85
+ },
86
+ OperatingSystem : takeFirst (orig .OperatingSystem , "linux" ),
87
+ StartupScript : sql.NullString {
88
+ String : takeFirst (orig .StartupScript .String , "" ),
89
+ Valid : takeFirst (orig .StartupScript .Valid , false ),
90
+ },
91
+ Directory : takeFirst (orig .Directory , "" ),
92
+ InstanceMetadata : pqtype.NullRawMessage {
93
+ RawMessage : takeFirstBytes (orig .ResourceMetadata .RawMessage , []byte ("{}" )),
94
+ Valid : takeFirst (orig .ResourceMetadata .Valid , false ),
95
+ },
96
+ ResourceMetadata : pqtype.NullRawMessage {
97
+ RawMessage : takeFirstBytes (orig .ResourceMetadata .RawMessage , []byte ("{}" )),
98
+ Valid : takeFirst (orig .ResourceMetadata .Valid , false ),
99
+ },
100
+ ConnectionTimeoutSeconds : takeFirst (orig .ConnectionTimeoutSeconds , 3600 ),
101
+ TroubleshootingURL : takeFirst (orig .TroubleshootingURL , "https://example.com" ),
102
+ MOTDFile : takeFirst (orig .TroubleshootingURL , "" ),
103
+ LoginBeforeReady : takeFirst (orig .LoginBeforeReady , false ),
104
+ StartupScriptTimeoutSeconds : takeFirst (orig .StartupScriptTimeoutSeconds , 3600 ),
105
+ })
106
+ require .NoError (t , err , "insert workspace agent" )
107
+ return workspace
108
+ }
109
+
69
110
func Workspace (t * testing.T , db database.Store , orig database.Workspace ) database.Workspace {
70
111
workspace , err := db .InsertWorkspace (context .Background (), database.InsertWorkspaceParams {
71
112
ID : takeFirst (orig .ID , uuid .New ()),
0 commit comments