@@ -1262,6 +1262,11 @@ func TestAPI(t *testing.T) {
1262
1262
deleteErrC :make (chan error ,1 ),
1263
1263
}
1264
1264
fakeDCCLI = & fakeDevcontainerCLI {
1265
+ readConfig : agentcontainers.DevcontainerConfig {
1266
+ Workspace : agentcontainers.DevcontainerWorkspace {
1267
+ WorkspaceFolder :"/workspaces/coder" ,
1268
+ },
1269
+ },
1265
1270
execErrC :make (chan func (cmd string ,args ... string )error ,1 ),
1266
1271
readConfigErrC :make (chan func (envs []string )error ,1 ),
1267
1272
}
@@ -1273,8 +1278,8 @@ func TestAPI(t *testing.T) {
1273
1278
Running :true ,
1274
1279
CreatedAt :time .Now (),
1275
1280
Labels :map [string ]string {
1276
- agentcontainers .DevcontainerLocalFolderLabel :"/workspaces " ,
1277
- agentcontainers .DevcontainerConfigFileLabel :"/workspace /.devcontainer/devcontainer.json" ,
1281
+ agentcontainers .DevcontainerLocalFolderLabel :"/home/coder/coder " ,
1282
+ agentcontainers .DevcontainerConfigFileLabel :"/home/coder/coder /.devcontainer/devcontainer.json" ,
1278
1283
},
1279
1284
}
1280
1285
)
@@ -1320,11 +1325,6 @@ func TestAPI(t *testing.T) {
1320
1325
1321
1326
// Allow initial agent creation and injection to succeed.
1322
1327
testutil .RequireSend (ctx ,t ,fakeSAC .createErrC ,nil )
1323
- testutil .RequireSend (ctx ,t ,fakeDCCLI .execErrC ,func (cmd string ,args ... string )error {
1324
- assert .Equal (t ,"pwd" ,cmd )
1325
- assert .Empty (t ,args )
1326
- return nil
1327
- })// Exec pwd.
1328
1328
testutil .RequireSend (ctx ,t ,fakeDCCLI .readConfigErrC ,func (envs []string )error {
1329
1329
assert .Contains (t ,envs ,"CODER_WORKSPACE_AGENT_NAME=test-container" )
1330
1330
assert .Contains (t ,envs ,"CODER_WORKSPACE_NAME=test-workspace" )
@@ -1350,7 +1350,7 @@ func TestAPI(t *testing.T) {
1350
1350
// Verify agent was created.
1351
1351
require .Len (t ,fakeSAC .created ,1 )
1352
1352
assert .Equal (t ,"test-container" ,fakeSAC .created [0 ].Name )
1353
- assert .Equal (t ,"/workspaces" ,fakeSAC .created [0 ].Directory )
1353
+ assert .Equal (t ,"/workspaces/coder " ,fakeSAC .created [0 ].Directory )
1354
1354
assert .Len (t ,fakeSAC .deleted ,0 )
1355
1355
1356
1356
t .Log ("Agent injected successfully, now testing reinjection into the same container..." )
@@ -1467,11 +1467,6 @@ func TestAPI(t *testing.T) {
1467
1467
testutil .RequireSend (ctx ,t ,fakeSAC .deleteErrC ,nil )
1468
1468
// Expect the agent to be recreated.
1469
1469
testutil .RequireSend (ctx ,t ,fakeSAC .createErrC ,nil )
1470
- testutil .RequireSend (ctx ,t ,fakeDCCLI .execErrC ,func (cmd string ,args ... string )error {
1471
- assert .Equal (t ,"pwd" ,cmd )
1472
- assert .Empty (t ,args )
1473
- return nil
1474
- })// Exec pwd.
1475
1470
testutil .RequireSend (ctx ,t ,fakeDCCLI .readConfigErrC ,func (envs []string )error {
1476
1471
assert .Contains (t ,envs ,"CODER_WORKSPACE_AGENT_NAME=test-container" )
1477
1472
assert .Contains (t ,envs ,"CODER_WORKSPACE_NAME=test-workspace" )
@@ -1814,7 +1809,6 @@ func TestAPI(t *testing.T) {
1814
1809
},
1815
1810
},
1816
1811
},
1817
- execErrC :make (chan func (cmd string ,args ... string )error ,1 ),
1818
1812
}
1819
1813
1820
1814
testContainer = codersdk.WorkspaceAgentContainer {
@@ -1861,15 +1855,9 @@ func TestAPI(t *testing.T) {
1861
1855
1862
1856
// Close before api.Close() defer to avoid deadlock after test.
1863
1857
defer close (fSAC .createErrC )
1864
- defer close (fDCCLI .execErrC )
1865
1858
1866
1859
// Given: We allow agent creation and injection to succeed.
1867
1860
testutil .RequireSend (ctx ,t ,fSAC .createErrC ,nil )
1868
- testutil .RequireSend (ctx ,t ,fDCCLI .execErrC ,func (cmd string ,args ... string )error {
1869
- assert .Equal (t ,"pwd" ,cmd )
1870
- assert .Empty (t ,args )
1871
- return nil
1872
- })
1873
1861
1874
1862
// Wait until the ticker has been registered.
1875
1863
tickerTrap .MustWait (ctx ).MustRelease (ctx )
@@ -1913,7 +1901,6 @@ func TestAPI(t *testing.T) {
1913
1901
},
1914
1902
},
1915
1903
readConfigErrC :make (chan func (envs []string )error ,2 ),
1916
- execErrC :make (chan func (cmd string ,args ... string )error ,1 ),
1917
1904
}
1918
1905
1919
1906
testContainer = codersdk.WorkspaceAgentContainer {
@@ -1960,16 +1947,10 @@ func TestAPI(t *testing.T) {
1960
1947
1961
1948
// Close before api.Close() defer to avoid deadlock after test.
1962
1949
defer close (fSAC .createErrC )
1963
- defer close (fDCCLI .execErrC )
1964
1950
defer close (fDCCLI .readConfigErrC )
1965
1951
1966
1952
// Given: We allow agent creation and injection to succeed.
1967
1953
testutil .RequireSend (ctx ,t ,fSAC .createErrC ,nil )
1968
- testutil .RequireSend (ctx ,t ,fDCCLI .execErrC ,func (cmd string ,args ... string )error {
1969
- assert .Equal (t ,"pwd" ,cmd )
1970
- assert .Empty (t ,args )
1971
- return nil
1972
- })
1973
1954
testutil .RequireSend (ctx ,t ,fDCCLI .readConfigErrC ,func (env []string )error {
1974
1955
// We expect the wrong workspace agent name passed in first.
1975
1956
assert .Contains (t ,env ,"CODER_WORKSPACE_AGENT_NAME=test-container" )