@@ -19,6 +19,7 @@ import (
1919"github.com/coder/coder/v2/coderd/coderdtest"
2020"github.com/coder/coder/v2/coderd/database"
2121"github.com/coder/coder/v2/coderd/database/dbtestutil"
22+ "github.com/coder/coder/v2/coderd/database/dbtime"
2223"github.com/coder/coder/v2/coderd/workspaceapps"
2324"github.com/coder/coder/v2/codersdk"
2425"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
@@ -93,11 +94,16 @@ func TestRegions(t *testing.T) {
9394deploymentID ,err := db .GetDeploymentID (ctx )
9495require .NoError (t ,err ,"get deployment ID" )
9596
97+ // The default proxy is always called "primary".
98+ primary ,err := client .WorkspaceProxyByName (ctx ,"primary" )
99+ require .NoError (t ,err )
100+
96101const proxyName = "hello"
97102_ = coderdenttest .NewWorkspaceProxy (t ,api ,client ,& coderdenttest.ProxyOptions {
98103Name :proxyName ,
99104AppHostname :appHostname + ".proxy" ,
100105})
106+ approxCreateTime := dbtime .Now ()
101107proxy ,err := db .GetWorkspaceProxyByName (ctx ,proxyName )
102108require .NoError (t ,err )
103109
@@ -135,7 +141,7 @@ func TestRegions(t *testing.T) {
135141require .NoError (t ,err )
136142require .Len (t ,regions ,2 )
137143
138- // Region 0 is the primaryrequire.Len(t, regions, 1)
144+ // Region 0 is the primary
139145require .NotEqual (t ,uuid .Nil ,regions [0 ].ID )
140146require .Equal (t ,regions [0 ].ID .String (),deploymentID )
141147require .Equal (t ,"primary" ,regions [0 ].Name )
@@ -145,6 +151,11 @@ func TestRegions(t *testing.T) {
145151require .Equal (t ,client .URL .String (),regions [0 ].PathAppURL )
146152require .Equal (t ,appHostname ,regions [0 ].WildcardHostname )
147153
154+ // Ensure non-zero fields of the default proxy
155+ require .NotZero (t ,primary .Name )
156+ require .NotZero (t ,primary .CreatedAt )
157+ require .NotZero (t ,primary .UpdatedAt )
158+
148159// Region 1 is the proxy.
149160require .NotEqual (t ,uuid .Nil ,regions [1 ].ID )
150161require .Equal (t ,proxy .ID ,regions [1 ].ID )
@@ -154,6 +165,11 @@ func TestRegions(t *testing.T) {
154165require .True (t ,regions [1 ].Healthy )
155166require .Equal (t ,proxy .Url ,regions [1 ].PathAppURL )
156167require .Equal (t ,proxy .WildcardHostname ,regions [1 ].WildcardHostname )
168+
169+ // Unfortunately need to wait to assert createdAt/updatedAt
170+ <- time .After (testutil .WaitShort / 10 )
171+ require .WithinDuration (t ,approxCreateTime ,proxy .CreatedAt ,testutil .WaitShort / 10 )
172+ require .WithinDuration (t ,approxCreateTime ,proxy .UpdatedAt ,testutil .WaitShort / 10 )
157173})
158174
159175t .Run ("RequireAuth" ,func (t * testing.T ) {