@@ -749,6 +749,7 @@ func TestAPI(t *testing.T) {
749749knownDevcontainers []codersdk.WorkspaceAgentDevcontainer
750750wantStatus int
751751wantCount int
752+ wantTestContainer bool
752753verify func (t * testing.T ,devcontainers []codersdk.WorkspaceAgentDevcontainer )
753754}{
754755{
@@ -995,6 +996,13 @@ func TestAPI(t *testing.T) {
995996assert .Len (t ,names ,4 ,"should have four unique devcontainer names" )
996997},
997998},
999+ {
1000+ name :"Include test containers" ,
1001+ lister :& fakeContainerCLI {},
1002+ wantStatus :http .StatusOK ,
1003+ wantTestContainer :true ,
1004+ wantCount :1 ,// Will be appended.
1005+ },
9981006}
9991007
10001008for _ ,tt := range tests {
@@ -1007,6 +1015,18 @@ func TestAPI(t *testing.T) {
10071015mClock .Set (time .Now ()).MustWait (testutil .Context (t ,testutil .WaitShort ))
10081016tickerTrap := mClock .Trap ().TickerFunc ("updaterLoop" )
10091017
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+
10101030// Setup router with the handler under test.
10111031r := chi .NewRouter ()
10121032apiOptions := []agentcontainers.Option {
@@ -1016,6 +1036,12 @@ func TestAPI(t *testing.T) {
10161036agentcontainers .WithWatcher (watcher .NewNoop ()),
10171037}
10181038
1039+ if tt .wantTestContainer {
1040+ apiOptions = append (apiOptions ,agentcontainers .WithContainerLabelIncludeFilter (
1041+ agentcontainers .DevcontainerIsTestRunLabel ,"true" ,
1042+ ))
1043+ }
1044+
10191045// Generate matching scripts for the known devcontainers
10201046// (required to extract log source ID).
10211047var scripts []codersdk.WorkspaceAgentScript