mengw15 opened a new pull request, #7881:
URL: https://github.com/apache/texera/pull/7881

   ### What changes were proposed in this PR?
   
   Extends `DatasetResourceSpec` to cover `DatasetResource`'s public (anonymous)
   read path, which no test called before: the presigned-download endpoints, the
   anonymous dataset read, and the file-node tree behind the version reads.
   
   Measured with JaCoCo, this takes `DatasetResource.scala` from **73.10 % to
   83.10 %** line coverage (78 → 49 uncovered lines).
   
   8 added tests:
   
   - `getPublicPresignedUrl` — returns a presigned address for a public 
dataset's file, and returns **400** when only one of `repositoryName` / 
`commitHash` is supplied (the shared `resolveDatasetAndPath` error arm).
   - `getPublicPresignedUrlWithS3` — the same for the S3 variant, plus a 
percent-encoded path (spaces and an escaped separator) that only resolves 
because the endpoint decodes the query parameter first.
   - `getPublicDataset` — returns the dashboard dataset for a public dataset, 
and raises `ForbiddenException` for a private one.
   - `retrievePublicDatasetVersionRootFileNodes` — returns the version's tree 
to an anonymous caller, asserting it is **assembled rather than flattened** (a 
directory keeps its own children, two levels deep) across files seeded under 
more than one directory.
   - `retrieveDatasetVersionRootFileNodes` — the authenticated sibling, which 
shared the same uncovered helper.
   
   Every region the issue named is now fully covered.
   
   ### Notes from writing these
   
   - **The presigned URL carries no file name.** It is MinIO's *physical* 
object address built from LakeFS's internal object ids 
(`…/<bucket>/<repositoryName>/data/<objectId>?X-Amz-…`). The tests therefore 
assert that the address belongs to the dataset under test (its unique 
`repositoryName`) and is actually signed (`X-Amz-Signature`) — no port and no 
absolute host, per the issue's determinism note.
   - **The file-node reads list committed objects,** so the helper commits and 
pins the returned hash rather than reading a branch head.
   - **`getDatasetVersionZip` was already covered** — the baseline report shows 
no uncovered lines there — so it is not duplicated here.
   - The `(None, None)` arm of `resolveDatasetAndPath` (lines 1644/1646/1667) 
is left uncovered: reaching it means driving `FileResolver.resolve` + 
`DocumentFactory.openReadonlyDocument` with a resolvable `texera://` URI, which 
is a different (and much heavier) fixture than this issue's scope.
   
   **Determinism.** Each test seeds its own dataset, repository and version, so
   nothing depends on another test's uploads or on the shared fixture's 
publicity,
   which existing tests mutate in place. Assertions are on structure — node 
names,
   nesting, status codes — never on byte sizes, timestamps, ports or absolute 
URLs.
   
   No production code was changed.
   
   ### Any related issues, documentation, discussions?
   
   Closes #7878
   
   ### How was this PR tested?
   
   Extended unit tests, run locally against the spec's existing embedded 
Postgres +
   LakeFS/MinIO mocks:
   
   ```
   sbt "FileService/testOnly *DatasetResourceSpec"
   # Tests: succeeded 138, failed 0
   sbt "FileService/test"      # whole module: 306 succeeded, 0 failed (twice)
   sbt "FileService/Test/scalafmtCheck" "FileService/Test/scalafix --check"   # 
clean
   sbt "FileService/jacoco"    # DatasetResource.scala: 73.10% -> 83.10%
   ```
   
   The failure path was verified by breaking the file-tree assertion and 
confirming
   the suite exits non-zero, then restoring it.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 4.8 [1M context])
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to