@@ -749,6 +749,7 @@ func TestAPI(t *testing.T) {
749
749
knownDevcontainers []codersdk.WorkspaceAgentDevcontainer
750
750
wantStatus int
751
751
wantCount int
752
+ wantTestContainer bool
752
753
verify func (t * testing.T , devcontainers []codersdk.WorkspaceAgentDevcontainer )
753
754
}{
754
755
{
@@ -995,6 +996,13 @@ func TestAPI(t *testing.T) {
995
996
assert .Len (t , names , 4 , "should have four unique devcontainer names" )
996
997
},
997
998
},
999
+ {
1000
+ name : "Include test containers" ,
1001
+ lister : & fakeContainerCLI {},
1002
+ wantStatus : http .StatusOK ,
1003
+ wantTestContainer : true ,
1004
+ wantCount : 1 , // Will be appended.
1005
+ },
998
1006
}
999
1007
1000
1008
for _ , tt := range tests {
@@ -1007,6 +1015,18 @@ func TestAPI(t *testing.T) {
1007
1015
mClock .Set (time .Now ()).MustWait (testutil .Context (t , testutil .WaitShort ))
1008
1016
tickerTrap := mClock .Trap ().TickerFunc ("updaterLoop" )
1009
1017
1018
+ // This container should be ignored unless explicitly included.
1019
+ tt .lister .containers .Containers = append (tt .lister .containers .Containers , codersdk.WorkspaceAgentContainer {
1020
+ ID : "test-container-1" ,
1021
+ FriendlyName : "test-container-1" ,
1022
+ Running : true ,
1023
+ Labels : map [string ]string {
1024
+ agentcontainers .DevcontainerLocalFolderLabel : "/workspace/test1" ,
1025
+ agentcontainers .DevcontainerConfigFileLabel : "/workspace/test1/.devcontainer/devcontainer.json" ,
1026
+ agentcontainers .DevcontainerIsTestRunLabel : "true" ,
1027
+ },
1028
+ })
1029
+
1010
1030
// Setup router with the handler under test.
1011
1031
r := chi .NewRouter ()
1012
1032
apiOptions := []agentcontainers.Option {
@@ -1016,6 +1036,12 @@ func TestAPI(t *testing.T) {
1016
1036
agentcontainers .WithWatcher (watcher .NewNoop ()),
1017
1037
}
1018
1038
1039
+ if tt .wantTestContainer {
1040
+ apiOptions = append (apiOptions , agentcontainers .WithContainerLabelIncludeFilter (
1041
+ agentcontainers .DevcontainerIsTestRunLabel , "true" ,
1042
+ ))
1043
+ }
1044
+
1019
1045
// Generate matching scripts for the known devcontainers
1020
1046
// (required to extract log source ID).
1021
1047
var scripts []codersdk.WorkspaceAgentScript
0 commit comments