This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-6699-6275b808286efea1cb9f3562f62ec9c4b9d67b03 in repository https://gitbox.apache.org/repos/asf/texera.git
commit 69286ac90fc3b2b968f5c53833ca11f2e781a7c9 Author: Matthew B. <[email protected]> AuthorDate: Tue Jul 21 18:54:25 2026 -0700 test(workflow-core): cover isFileResolved and parse owner (#6699) ### What changes were proposed in this PR? - Add unit tests for FileResolver.isFileResolved covering non-empty scheme, missing scheme, and malformed URI cases. - Add unit tests for FileResolver.parseDatasetOwnerAndName covering valid paths, too few segments, and a null path. ### Any related issues, documentation, discussions? Closes: #6698 ### How was this PR tested? - Run: `sbt "WorkflowCore/testOnly *FileResolverSpec"`, expect all 9 tests passing. - Test-only change; no production code is modified. ### Was this PR authored or co-authored using generative AI tooling? Co-authored with Claude Opus 4.8 in compliance with ASF --- .../texera/amber/storage/FileResolverSpec.scala | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/common/workflow-core/src/test/scala/org/apache/texera/amber/storage/FileResolverSpec.scala b/common/workflow-core/src/test/scala/org/apache/texera/amber/storage/FileResolverSpec.scala index 593ac8d347..62daa811d3 100644 --- a/common/workflow-core/src/test/scala/org/apache/texera/amber/storage/FileResolverSpec.scala +++ b/common/workflow-core/src/test/scala/org/apache/texera/amber/storage/FileResolverSpec.scala @@ -124,6 +124,44 @@ class FileResolverSpec } } + "isFileResolved" should "return true when the path has a non-empty scheme" in { + assert(FileResolver.isFileResolved("s3://bucket/key")) + assert( + FileResolver.isFileResolved(s"${FileResolver.DATASET_FILE_URI_SCHEME}:///repo/hash/file.csv") + ) + } + + it should "return false when the path has no scheme" in { + assert(!FileResolver.isFileResolved("some/random/path")) + assert(!FileResolver.isFileResolved("/[email protected]/test_dataset/v1/1.txt")) + } + + it should "return false for a malformed URI" in { + // a space is illegal in a URI and makes the java.net.URI constructor throw + assert(!FileResolver.isFileResolved("has a space")) + } + + "parseDatasetOwnerAndName" should "extract owner email and dataset name from a valid path" in { + assert( + FileResolver.parseDatasetOwnerAndName("/[email protected]/test_dataset/v1/1.txt") + == Some(("[email protected]", "test_dataset")) + ) + // extra segments beyond the file-relative path are ignored + assert( + FileResolver.parseDatasetOwnerAndName("/[email protected]/ds/v2/directory/nested/a.csv") + == Some(("[email protected]", "ds")) + ) + } + + it should "return None when the path has fewer than four segments" in { + assert(FileResolver.parseDatasetOwnerAndName("/[email protected]/ds/v1").isEmpty) + assert(FileResolver.parseDatasetOwnerAndName("owner/dataset").isEmpty) + } + + it should "return None for a null path" in { + assert(FileResolver.parseDatasetOwnerAndName(null).isEmpty) + } + override protected def afterAll(): Unit = { shutdownDB() }
