@@ -15,9 +15,10 @@ import (
1515
1616func TestFindWorkspaces (t * testing.T ) {
1717 repos := []* graphql.Repository {
18- {ID : "repo-id-0" , Name : "github.com/sourcegraph/automation-testing" },
19- {ID : "repo-id-1" , Name : "github.com/sourcegraph/sourcegraph" },
20- {ID : "repo-id-2" , Name : "bitbucket.sgdev.org/SOUR/automation-testing" },
18+ {ID : "repo-id-0" , Name : "github.com/sourcegraph/automation-testing" , FileMatches : map [string ]bool {}},
19+ {ID : "repo-id-1" , Name : "github.com/sourcegraph/sourcegraph" , FileMatches : map [string ]bool {}},
20+ {ID : "repo-id-2" , Name : "bitbucket.sgdev.org/SOUR/automation-testing" , FileMatches : map [string ]bool {}},
21+ {ID : "repo-id-3" , Name : "github.com/sourcegraph/src-cli" , FileMatches : map [string ]bool {"a/b" : true , "a/b/c" : true , "d/e/f" : true }},
2122 }
2223 steps := []batcheslib.Step {{Run : "echo 1" }}
2324
@@ -37,6 +38,7 @@ func TestFindWorkspaces(t *testing.T) {
3738 {Repo : repos [0 ], Path : "" },
3839 {Repo : repos [1 ], Path : "" },
3940 {Repo : repos [2 ], Path : "" },
41+ {Repo : repos [3 ], Path : "" },
4042 },
4143 },
4244
@@ -52,10 +54,11 @@ func TestFindWorkspaces(t *testing.T) {
5254 {Repo : repos [0 ], Path : "" },
5355 {Repo : repos [1 ], Path : "" },
5456 {Repo : repos [2 ], Path : "" },
57+ {Repo : repos [3 ], Path : "" },
5558 },
5659 },
5760
58- "workspace configuration matching 2 repos with no results" : {
61+ "workspace configuration matching 3 repos with no results" : {
5962 spec : & batcheslib.BatchSpec {
6063 Steps : steps ,
6164 Workspaces : []batcheslib.WorkspaceConfiguration {
@@ -68,6 +71,7 @@ func TestFindWorkspaces(t *testing.T) {
6871 },
6972 wantWorkspaces : []RepoWorkspace {
7073 {Repo : repos [1 ], Path : "" },
74+ {Repo : repos [3 ], Path : "" },
7175 },
7276 },
7377
@@ -90,6 +94,7 @@ func TestFindWorkspaces(t *testing.T) {
9094 {Repo : repos [2 ], Path : "a/b" },
9195 {Repo : repos [2 ], Path : "a/b/c" },
9296 {Repo : repos [2 ], Path : "d/e/f" },
97+ {Repo : repos [3 ], Path : "" },
9398 },
9499 },
95100
@@ -116,6 +121,7 @@ func TestFindWorkspaces(t *testing.T) {
116121 {Repo : repos [2 ], Path : "a/b" , OnlyFetchWorkspace : true },
117122 {Repo : repos [2 ], Path : "a/b/c" , OnlyFetchWorkspace : true },
118123 {Repo : repos [2 ], Path : "d/e/f" , OnlyFetchWorkspace : true },
124+ {Repo : repos [3 ], Path : "" },
119125 },
120126 },
121127 "workspace configuration without 'in' matches all" : {
@@ -136,6 +142,53 @@ func TestFindWorkspaces(t *testing.T) {
136142 {Repo : repos [2 ], Path : "a/b" },
137143 },
138144 },
145+ "workspace gets subset of search_result_paths" : {
146+ spec : & batcheslib.BatchSpec {
147+ Steps : steps ,
148+ Workspaces : []batcheslib.WorkspaceConfiguration {
149+ {
150+ In : "*src-cli" ,
151+ RootAtLocationOf : "package.json" ,
152+ },
153+ },
154+ },
155+ finderResults : finderResults {
156+ repos [3 ]: {"a/b" , "d" },
157+ },
158+ wantWorkspaces : []RepoWorkspace {
159+ {Repo : repos [0 ], Path : "" },
160+ {Repo : repos [1 ], Path : "" },
161+ {Repo : repos [2 ], Path : "" },
162+ {
163+ Repo : & graphql.Repository {
164+ ID : repos [3 ].ID ,
165+ Name : repos [3 ].Name ,
166+ URL : repos [3 ].URL ,
167+ ExternalRepository : repos [3 ].ExternalRepository ,
168+ DefaultBranch : repos [3 ].DefaultBranch ,
169+ Branch : repos [3 ].Branch ,
170+ Commit : repos [3 ].Commit ,
171+ // Only expect the file matches that are children of a/b.
172+ FileMatches : map [string ]bool {"a/b" : true , "a/b/c" : true },
173+ },
174+ Path : "a/b" ,
175+ },
176+ {
177+ Repo : & graphql.Repository {
178+ ID : repos [3 ].ID ,
179+ Name : repos [3 ].Name ,
180+ URL : repos [3 ].URL ,
181+ ExternalRepository : repos [3 ].ExternalRepository ,
182+ DefaultBranch : repos [3 ].DefaultBranch ,
183+ Branch : repos [3 ].Branch ,
184+ Commit : repos [3 ].Commit ,
185+ // Only expect the file matches that are children of d.
186+ FileMatches : map [string ]bool {"d/e/f" : true },
187+ },
188+ Path : "d" ,
189+ },
190+ },
191+ },
139192 }
140193
141194 for name , tt := range tests {
0 commit comments