@@ -437,6 +437,7 @@ func TestAPI(t *testing.T) {
437
437
agentcontainers .WithContainerCLI (mLister ),
438
438
agentcontainers .WithContainerLabelIncludeFilter ("this.label.does.not.exist.ignore.devcontainers" , "true" ),
439
439
)
440
+ api .Init ()
440
441
defer api .Close ()
441
442
r .Mount ("/" , api .Routes ())
442
443
@@ -614,6 +615,7 @@ func TestAPI(t *testing.T) {
614
615
agentcontainers .WithDevcontainerCLI (tt .devcontainerCLI ),
615
616
agentcontainers .WithWatcher (watcher .NewNoop ()),
616
617
)
618
+ api .Init ()
617
619
defer api .Close ()
618
620
r .Mount ("/" , api .Routes ())
619
621
@@ -1027,6 +1029,7 @@ func TestAPI(t *testing.T) {
1027
1029
}
1028
1030
1029
1031
api := agentcontainers .NewAPI (logger , apiOptions ... )
1032
+ api .Init ()
1030
1033
defer api .Close ()
1031
1034
1032
1035
r .Mount ("/" , api .Routes ())
@@ -1111,6 +1114,7 @@ func TestAPI(t *testing.T) {
1111
1114
[]codersdk.WorkspaceAgentScript {{LogSourceID : uuid .New (), ID : dc .ID }},
1112
1115
),
1113
1116
)
1117
+ api .Init ()
1114
1118
defer api .Close ()
1115
1119
1116
1120
// Make sure the ticker function has been registered
@@ -1206,6 +1210,7 @@ func TestAPI(t *testing.T) {
1206
1210
agentcontainers .WithWatcher (fWatcher ),
1207
1211
agentcontainers .WithClock (mClock ),
1208
1212
)
1213
+ api .Init ()
1209
1214
defer api .Close ()
1210
1215
1211
1216
r := chi .NewRouter ()
@@ -1358,6 +1363,7 @@ func TestAPI(t *testing.T) {
1358
1363
agentcontainers .WithDevcontainerCLI (fakeDCCLI ),
1359
1364
agentcontainers .WithManifestInfo ("test-user" , "test-workspace" ),
1360
1365
)
1366
+ api .Init ()
1361
1367
apiClose := func () {
1362
1368
closeOnce .Do (func () {
1363
1369
// Close before api.Close() defer to avoid deadlock after test.
@@ -1578,6 +1584,7 @@ func TestAPI(t *testing.T) {
1578
1584
agentcontainers .WithSubAgentClient (fakeSAC ),
1579
1585
agentcontainers .WithDevcontainerCLI (& fakeDevcontainerCLI {}),
1580
1586
)
1587
+ api .Init ()
1581
1588
defer api .Close ()
1582
1589
1583
1590
tickerTrap .MustWait (ctx ).MustRelease (ctx )
@@ -1899,6 +1906,7 @@ func TestAPI(t *testing.T) {
1899
1906
agentcontainers .WithSubAgentURL ("test-subagent-url" ),
1900
1907
agentcontainers .WithWatcher (watcher .NewNoop ()),
1901
1908
)
1909
+ api .Init ()
1902
1910
defer api .Close ()
1903
1911
1904
1912
// Close before api.Close() defer to avoid deadlock after test.
@@ -1991,6 +1999,7 @@ func TestAPI(t *testing.T) {
1991
1999
agentcontainers .WithSubAgentURL ("test-subagent-url" ),
1992
2000
agentcontainers .WithWatcher (watcher .NewNoop ()),
1993
2001
)
2002
+ api .Init ()
1994
2003
defer api .Close ()
1995
2004
1996
2005
// Close before api.Close() defer to avoid deadlock after test.
@@ -2045,6 +2054,7 @@ func TestAPI(t *testing.T) {
2045
2054
agentcontainers .WithExecer (fakeExec ),
2046
2055
agentcontainers .WithCommandEnv (commandEnv ),
2047
2056
)
2057
+ api .Init ()
2048
2058
defer api .Close ()
2049
2059
2050
2060
// Call RefreshContainers directly to trigger CommandEnv usage.
@@ -2134,6 +2144,7 @@ func TestAPI(t *testing.T) {
2134
2144
agentcontainers .WithWatcher (fWatcher ),
2135
2145
agentcontainers .WithClock (mClock ),
2136
2146
)
2147
+ api .Init ()
2137
2148
defer func () {
2138
2149
close (fakeSAC .createErrC )
2139
2150
close (fakeSAC .deleteErrC )
@@ -2334,6 +2345,7 @@ func TestSubAgentCreationWithNameRetry(t *testing.T) {
2334
2345
agentcontainers .WithSubAgentClient (fSAC ),
2335
2346
agentcontainers .WithWatcher (watcher .NewNoop ()),
2336
2347
)
2348
+ api .Init ()
2337
2349
defer api .Close ()
2338
2350
2339
2351
tickerTrap .MustWait (ctx ).MustRelease (ctx )
0 commit comments