File tree Expand file tree Collapse file tree 3 files changed +19
-15
lines changed
components/remote_settings/src Expand file tree Collapse file tree 3 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -1603,10 +1603,12 @@ mod test_filtering_records {
16031603 last_modified: 100 ,
16041604 deleted: false ,
16051605 attachment: None ,
1606- fields: json!( { "filter_expression" : "app_version|versionCompare('4.0') >= 0" } )
1607- . as_object( )
1608- . unwrap( )
1609- . clone( ) ,
1606+ fields: json!( {
1607+ "filter_expression" : "env.version|versionCompare(\" 128.0a1\" ) > 0"
1608+ } )
1609+ . as_object( )
1610+ . unwrap( )
1611+ . clone( ) ,
16101612 } ] ;
16111613 api_client. expect_collection_url ( ) . returning ( || {
16121614 "http://rs.example.com/v1/buckets/main/collections/test-collection" . into ( )
@@ -1620,7 +1622,7 @@ mod test_filtering_records {
16201622 } ) ;
16211623
16221624 let context = RemoteSettingsContext {
1623- app_version : Some ( "4.4 " . to_string ( ) ) ,
1625+ app_version : Some ( "129.0.0 " . to_string ( ) ) ,
16241626 ..Default :: default ( )
16251627 } ;
16261628
@@ -1650,10 +1652,12 @@ mod test_filtering_records {
16501652 last_modified: 100 ,
16511653 deleted: false ,
16521654 attachment: None ,
1653- fields: json!( { "filter_expression" : "app_version|versionCompare('4.0') >= 0" } )
1654- . as_object( )
1655- . unwrap( )
1656- . clone( ) ,
1655+ fields: json!( {
1656+ "filter_expression" : "env.version|versionCompare(\" 128.0a1\" ) > 0"
1657+ } )
1658+ . as_object( )
1659+ . unwrap( )
1660+ . clone( ) ,
16571661 } ] ;
16581662 api_client. expect_collection_url ( ) . returning ( || {
16591663 "http://rs.example.com/v1/buckets/main/collections/test-collection" . into ( )
@@ -1667,7 +1671,7 @@ mod test_filtering_records {
16671671 } ) ;
16681672
16691673 let context = RemoteSettingsContext {
1670- app_version : Some ( "3.9 " . to_string ( ) ) ,
1674+ app_version : Some ( "127.0.0. " . to_string ( ) ) ,
16711675 ..Default :: default ( )
16721676 } ;
16731677
Original file line number Diff line number Diff line change @@ -26,16 +26,15 @@ impl JexlFilter {
2626 pub ( crate ) fn new ( context : Option < RemoteSettingsContext > ) -> Self {
2727 let env_context = match context {
2828 Some ( ctx) => {
29- serde_json:: to_value ( ctx) . expect ( "Failed to serialize RemoteSettingsContext" )
29+ let serialized_context =
30+ serde_json:: to_value ( ctx) . expect ( "Failed to serialize RemoteSettingsContext" ) ;
31+ json ! ( { "env" : serialized_context } )
3032 }
31- None => json ! ( { } ) ,
33+ None => json ! ( { "env" : { } } ) ,
3234 } ;
3335
3436 Self {
3537 evaluator : Evaluator :: new ( )
36- // We want to add more transforms later on. We started with `versionCompare`.
37- // https://remote-settings.readthedocs.io/en/latest/target-filters.html#transforms
38- // The goal is to get on pare with the desktop.
3938 . with_transform ( "versionCompare" , |args| Ok ( version_compare ( args) ?) ) ,
4039 context : env_context,
4140 }
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ pub struct RemoteSettingsContext {
4444 /// The delivery channel of the application (e.g "nightly")
4545 pub channel : String ,
4646 /// User visible version string (e.g. "1.0.3")
47+ #[ serde( rename = "version" ) ]
4748 pub app_version : Option < String > ,
4849 /// Build identifier generated by the CI system (e.g. "1234/A")
4950 pub app_build : Option < String > ,
You can’t perform that action at this time.
0 commit comments