@@ -747,6 +747,7 @@ func TestAPI(t *testing.T) {
747
747
knownDevcontainers []codersdk.WorkspaceAgentDevcontainer
748
748
wantStatus int
749
749
wantCount int
750
+ wantTestContainer bool
750
751
verify func (t * testing.T , devcontainers []codersdk.WorkspaceAgentDevcontainer )
751
752
}{
752
753
{
@@ -793,16 +794,6 @@ func TestAPI(t *testing.T) {
793
794
agentcontainers .DevcontainerConfigFileLabel : "/workspace/runtime1/.devcontainer/devcontainer.json" ,
794
795
},
795
796
},
796
- {
797
- ID : "test-container-1" ,
798
- FriendlyName : "test-container-1" ,
799
- Running : true ,
800
- Labels : map [string ]string {
801
- agentcontainers .DevcontainerLocalFolderLabel : "/workspace/test1" ,
802
- agentcontainers .DevcontainerConfigFileLabel : "/workspace/test1/.devcontainer/devcontainer.json" ,
803
- agentcontainers .DevcontainerIsTestRunLabel : "true" ,
804
- },
805
- },
806
797
{
807
798
ID : "not-a-devcontainer" ,
808
799
FriendlyName : "not-a-devcontainer" ,
@@ -845,16 +836,6 @@ func TestAPI(t *testing.T) {
845
836
agentcontainers .DevcontainerConfigFileLabel : "/workspace/runtime1/.devcontainer/devcontainer.json" ,
846
837
},
847
838
},
848
- {
849
- ID : "test-container-1" ,
850
- FriendlyName : "test-container-1" ,
851
- Running : true ,
852
- Labels : map [string ]string {
853
- agentcontainers .DevcontainerLocalFolderLabel : "/workspace/test1" ,
854
- agentcontainers .DevcontainerConfigFileLabel : "/workspace/test1/.devcontainer/devcontainer.json" ,
855
- agentcontainers .DevcontainerIsTestRunLabel : "true" ,
856
- },
857
- },
858
839
},
859
840
},
860
841
},
@@ -901,16 +882,6 @@ func TestAPI(t *testing.T) {
901
882
agentcontainers .DevcontainerConfigFileLabel : "/workspace/non-running/.devcontainer/devcontainer.json" ,
902
883
},
903
884
},
904
- {
905
- ID : "test-container-1" ,
906
- FriendlyName : "test-container-1" ,
907
- Running : true ,
908
- Labels : map [string ]string {
909
- agentcontainers .DevcontainerLocalFolderLabel : "/workspace/test1" ,
910
- agentcontainers .DevcontainerConfigFileLabel : "/workspace/test1/.devcontainer/devcontainer.json" ,
911
- agentcontainers .DevcontainerIsTestRunLabel : "true" ,
912
- },
913
- },
914
885
},
915
886
},
916
887
},
@@ -944,16 +915,6 @@ func TestAPI(t *testing.T) {
944
915
agentcontainers .DevcontainerConfigFileLabel : "/workspace/known2/.devcontainer/devcontainer.json" ,
945
916
},
946
917
},
947
- {
948
- ID : "test-container-1" ,
949
- FriendlyName : "test-container-1" ,
950
- Running : true ,
951
- Labels : map [string ]string {
952
- agentcontainers .DevcontainerLocalFolderLabel : "/workspace/test1" ,
953
- agentcontainers .DevcontainerConfigFileLabel : "/workspace/test1/.devcontainer/devcontainer.json" ,
954
- agentcontainers .DevcontainerIsTestRunLabel : "true" ,
955
- },
956
- },
957
918
},
958
919
},
959
920
},
@@ -1007,16 +968,6 @@ func TestAPI(t *testing.T) {
1007
968
agentcontainers .DevcontainerConfigFileLabel : "/var/lib/project3/.devcontainer/devcontainer.json" ,
1008
969
},
1009
970
},
1010
- {
1011
- ID : "test-container-1" ,
1012
- FriendlyName : "test-container-1" ,
1013
- Running : true ,
1014
- Labels : map [string ]string {
1015
- agentcontainers .DevcontainerLocalFolderLabel : "/workspace/test1" ,
1016
- agentcontainers .DevcontainerConfigFileLabel : "/workspace/test1/.devcontainer/devcontainer.json" ,
1017
- agentcontainers .DevcontainerIsTestRunLabel : "true" ,
1018
- },
1019
- },
1020
971
},
1021
972
},
1022
973
},
@@ -1043,6 +994,13 @@ func TestAPI(t *testing.T) {
1043
994
assert .Len (t , names , 4 , "should have four unique devcontainer names" )
1044
995
},
1045
996
},
997
+ {
998
+ name : "Include test containers" ,
999
+ lister : & fakeContainerCLI {},
1000
+ wantStatus : http .StatusOK ,
1001
+ wantTestContainer : true ,
1002
+ wantCount : 1 , // Will be appended.
1003
+ },
1046
1004
}
1047
1005
1048
1006
for _ , tt := range tests {
@@ -1055,6 +1013,18 @@ func TestAPI(t *testing.T) {
1055
1013
mClock .Set (time .Now ()).MustWait (testutil .Context (t , testutil .WaitShort ))
1056
1014
tickerTrap := mClock .Trap ().TickerFunc ("updaterLoop" )
1057
1015
1016
+ // This container should be ignored unless explicitly included.
1017
+ tt .lister .containers .Containers = append (tt .lister .containers .Containers , codersdk.WorkspaceAgentContainer {
1018
+ ID : "test-container-1" ,
1019
+ FriendlyName : "test-container-1" ,
1020
+ Running : true ,
1021
+ Labels : map [string ]string {
1022
+ agentcontainers .DevcontainerLocalFolderLabel : "/workspace/test1" ,
1023
+ agentcontainers .DevcontainerConfigFileLabel : "/workspace/test1/.devcontainer/devcontainer.json" ,
1024
+ agentcontainers .DevcontainerIsTestRunLabel : "true" ,
1025
+ },
1026
+ })
1027
+
1058
1028
// Setup router with the handler under test.
1059
1029
r := chi .NewRouter ()
1060
1030
apiOptions := []agentcontainers.Option {
@@ -1063,6 +1033,12 @@ func TestAPI(t *testing.T) {
1063
1033
agentcontainers .WithWatcher (watcher .NewNoop ()),
1064
1034
}
1065
1035
1036
+ if tt .wantTestContainer {
1037
+ apiOptions = append (apiOptions , agentcontainers .WithContainerLabelIncludeFilter (
1038
+ agentcontainers .DevcontainerIsTestRunLabel , "true" ,
1039
+ ))
1040
+ }
1041
+
1066
1042
// Generate matching scripts for the known devcontainers
1067
1043
// (required to extract log source ID).
1068
1044
var scripts []codersdk.WorkspaceAgentScript
0 commit comments