@@ -14,6 +14,7 @@ import (
14
14
"github.com/coder/coder/coderd/database"
15
15
"github.com/coder/coder/coderd/database/dbgen"
16
16
"github.com/coder/coder/coderd/database/migrations"
17
+ "github.com/coder/coder/testutil"
17
18
)
18
19
19
20
func TestGetDeploymentWorkspaceAgentStats (t * testing.T ) {
@@ -257,3 +258,57 @@ func TestProxyByHostname(t *testing.T) {
257
258
})
258
259
}
259
260
}
261
+
262
+ func TestDefaultProxy (t * testing.T ) {
263
+ t .Parallel ()
264
+ if testing .Short () {
265
+ t .SkipNow ()
266
+ }
267
+ sqlDB := testSQLDB (t )
268
+ err := migrations .Up (sqlDB )
269
+ require .NoError (t , err )
270
+ db := database .New (sqlDB )
271
+
272
+ ctx := testutil .Context (t , testutil .WaitLong )
273
+ depID := uuid .NewString ()
274
+ err = db .InsertDeploymentID (ctx , depID )
275
+ require .NoError (t , err , "insert deployment id" )
276
+
277
+ // Fetch empty proxy values
278
+ defProxy , err := db .GetDefaultProxyConfig (ctx )
279
+ require .NoError (t , err , "get def proxy" )
280
+
281
+ require .Equal (t , defProxy .DisplayName , "Default" )
282
+ require .Equal (t , defProxy .IconUrl , "/emojis/1f3e1.png" )
283
+
284
+ // Set the proxy values
285
+ args := database.UpsertDefaultProxyParams {
286
+ DisplayName : "displayname" ,
287
+ IconUrl : "/icon.png" ,
288
+ }
289
+ err = db .UpsertDefaultProxy (ctx , args )
290
+ require .NoError (t , err , "insert def proxy" )
291
+
292
+ defProxy , err = db .GetDefaultProxyConfig (ctx )
293
+ require .NoError (t , err , "get def proxy" )
294
+ require .Equal (t , defProxy .DisplayName , args .DisplayName )
295
+ require .Equal (t , defProxy .IconUrl , args .IconUrl )
296
+
297
+ // Upsert values
298
+ args = database.UpsertDefaultProxyParams {
299
+ DisplayName : "newdisplayname" ,
300
+ IconUrl : "/newicon.png" ,
301
+ }
302
+ err = db .UpsertDefaultProxy (ctx , args )
303
+ require .NoError (t , err , "upsert def proxy" )
304
+
305
+ defProxy , err = db .GetDefaultProxyConfig (ctx )
306
+ require .NoError (t , err , "get def proxy" )
307
+ require .Equal (t , defProxy .DisplayName , args .DisplayName )
308
+ require .Equal (t , defProxy .IconUrl , args .IconUrl )
309
+
310
+ // Ensure other site configs are the same
311
+ found , err := db .GetDeploymentID (ctx )
312
+ require .NoError (t , err , "get deployment id" )
313
+ require .Equal (t , depID , found )
314
+ }
0 commit comments