Skip to content

Commit

Permalink
Sort output of S3_File.list and Enso_File.list (#11929)
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoryTravis authored Jan 10, 2025
1 parent ff1a6b4 commit 7ceb1fb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from Standard.Base import all
import Standard.Base.Data.Ordering.Vector_Lexicographic_Order
import Standard.Base.Enso_Cloud.Data_Link.Data_Link
import Standard.Base.Enso_Cloud.Data_Link.Data_Link_From_File
import Standard.Base.Enso_Cloud.Data_Link_Helpers
Expand Down Expand Up @@ -195,7 +196,7 @@ type S3_File
S3_File.Value (S3_Path.Value bucket key) self.credentials
files = pair.second . map key->
S3_File.Value (S3_Path.Value bucket key) self.credentials
sub_folders + files
(sub_folders + files) . sort on=.path

## ALIAS load bytes, open bytes
ICON data_input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import project.Any.Any
import project.Data.Color.Color
import project.Data.Json.JS_Object
import project.Data.Ordering.Vector_Lexicographic_Order
import project.Data.Numbers.Integer
import project.Data.Text.Encoding.Encoding
import project.Data.Text.Text
Expand Down Expand Up @@ -488,10 +489,11 @@ type Enso_File
if self.is_directory.not then Error.throw (Illegal_Argument.Error "Cannot `list` a non-directory.") else
# Remove secrets from the list - they are handled separately in `Enso_Secret.list`.
assets = list_assets self . filter f-> f.asset_type != Enso_Asset_Type.Secret
assets.map asset->
results = assets.map asset->
file = Enso_File.Value (self.enso_path.resolve asset.name)
Asset_Cache.update file asset
file
results.sort on=.path

## GROUP Output
ICON folder_add
Expand Down
6 changes: 6 additions & 0 deletions test/AWS_Tests/src/S3_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ add_specs suite_builder =
r3.should_be_a Vector
r3.map .name . should_contain object_name

group_builder.specify "list should sort its output" <|
r = root.list
r.should_be_a Vector
as_strings = r.map .to_text
as_strings . should_equal as_strings.sort

group_builder.specify "should be able to list buckets by constructing a root object" <|
with_default_credentials <|
just_s3 = File.new "s3://"
Expand Down
6 changes: 6 additions & 0 deletions test/Base_Tests/src/Network/Enso_Cloud/Enso_File_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ add_specs suite_builder setup:Cloud_Tests_Setup = suite_builder.group "Enso Clou
Data.list test_root.get . map .name . should_contain "test_file.json"
Data.list test_root.get.path . map .name . should_contain "test_file.json"

group_builder.specify "list should sort its output" <|
r = Enso_File.home.list
r.should_be_a Vector
as_strings = r.map .to_text
as_strings . should_equal as_strings.sort

group_builder.specify "should allow to create and delete a directory" <|
my_name = "my_test_dir-" + (Random.uuid.take 5)
my_dir = (test_root.get / my_name).create_directory
Expand Down

0 comments on commit 7ceb1fb

Please sign in to comment.