@@ -118,6 +118,8 @@ async fn test_ls_shows_remote_packages_with_host_default_filter() {
118
118
remote_repo. publish_recipe ( & recipe) . await . unwrap ( ) ;
119
119
let host_options = HOST_OPTIONS . get ( ) . unwrap ( ) ;
120
120
let os_id = host_options. get ( OptName :: distro ( ) ) . unwrap ( ) ;
121
+
122
+ // Build with all matching host options
121
123
let spec = spec ! ( { "pkg" : "my-pkg/1.0.0/BGSHW3CN" ,
122
124
"build" : {
123
125
"options" :
@@ -140,7 +142,78 @@ async fn test_ls_shows_remote_packages_with_host_default_filter() {
140
142
141
143
let mut opt = Opt :: try_parse_from ( [ "ls" , "--host" ] ) . unwrap ( ) ;
142
144
opt. ls . run ( ) . await . unwrap ( ) ;
143
- assert_ne ! ( opt. ls. output. vec. len( ) , 0 ) ;
145
+ assert_eq ! ( opt. ls. output. vec. len( ) , 1 ) ;
146
+ }
147
+
148
+ /// `spk ls` is expected to list packages in the configured remote
149
+ /// repositories that match the default filter for the current host
150
+ #[ tokio:: test]
151
+ async fn test_ls_shows_remote_packages_with_host_default_filter_multiple_builds ( ) {
152
+ let mut rt = spfs_runtime ( ) . await ;
153
+ let remote_repo = spfsrepo ( ) . await ;
154
+
155
+ // Populate the "origin" repo with one package.
156
+ // The "local" repo is empty.
157
+
158
+ rt. add_remote_repo (
159
+ "origin" ,
160
+ Remote :: Address ( RemoteAddress {
161
+ address : remote_repo. address ( ) . clone ( ) ,
162
+ } ) ,
163
+ )
164
+ . unwrap ( ) ;
165
+
166
+ let recipe = recipe ! ( { "pkg" : "my-pkg/1.0.0" } ) ;
167
+ remote_repo. publish_recipe ( & recipe) . await . unwrap ( ) ;
168
+ let host_options = HOST_OPTIONS . get ( ) . unwrap ( ) ;
169
+ let os_id = host_options. get ( OptName :: distro ( ) ) . unwrap ( ) ;
170
+
171
+ // Build with all matching host options
172
+ let spec = spec ! ( { "pkg" : "my-pkg/1.0.0/BGSHW3CN" ,
173
+ "build" : {
174
+ "options" :
175
+ [
176
+ { "var" : format!( "{}/{}" , OptName :: distro( ) , host_options. get( OptName :: distro( ) ) . unwrap( ) ) } ,
177
+ { "var" : format!( "{}/{}" , OptName :: os( ) , host_options. get( OptName :: os( ) ) . unwrap( ) ) } ,
178
+ { "var" : format!( "{}/{}" , OptName :: arch( ) , host_options. get( OptName :: arch( ) ) . unwrap( ) ) } ,
179
+ { "var" : format!( "{}/{}" , os_id, host_options. get( os_id) . unwrap( ) ) }
180
+ ]
181
+ } } ) ;
182
+ remote_repo
183
+ . publish_package (
184
+ & spec,
185
+ & vec ! [ ( Component :: Run , empty_layer_digest( ) ) ]
186
+ . into_iter ( )
187
+ . collect ( ) ,
188
+ )
189
+ . await
190
+ . unwrap ( ) ;
191
+
192
+ // Build with for another distro in its host options
193
+ let spec = spec ! ( { "pkg" : "my-pkg/1.0.0/2RGMWL2B" ,
194
+ "build" : {
195
+ "options" :
196
+ [
197
+ { "var" : format!( "{}/{}" , OptName :: distro( ) , "test_distro" ) } ,
198
+ { "var" : format!( "{}/{}" , OptName :: os( ) , host_options. get( OptName :: os( ) ) . unwrap( ) ) } ,
199
+ { "var" : format!( "{}/{}" , OptName :: arch( ) , host_options. get( OptName :: arch( ) ) . unwrap( ) ) } ,
200
+ { "var" : format!( "{}/{}" , os_id, host_options. get( os_id) . unwrap( ) ) }
201
+ ]
202
+ } } ) ;
203
+ remote_repo
204
+ . publish_package (
205
+ & spec,
206
+ & vec ! [ ( Component :: Run , empty_layer_digest( ) ) ]
207
+ . into_iter ( )
208
+ . collect ( ) ,
209
+ )
210
+ . await
211
+ . unwrap ( ) ;
212
+
213
+ let mut opt = Opt :: try_parse_from ( [ "ls" , "--host" ] ) . unwrap ( ) ;
214
+ opt. ls . run ( ) . await . unwrap ( ) ;
215
+ println ! ( "Output: {:?}" , opt. ls. output. vec) ;
216
+ assert_eq ! ( opt. ls. output. vec. len( ) , 1 ) ;
144
217
}
145
218
146
219
/// `spk ls` is expected to list packages in both the local and the configured
0 commit comments