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

   ### What changes were proposed in this PR?
   
   Extends `DatasetResourceSpec` with 12 tests for the six endpoints/helpers 
the issue
   lists, none of which any test reached before (`grep` for each name in the 
spec
   returned nothing). Measured with `sbt FileService/jacoco` on a clean 
`jacoco.exec`,
   before and after:
   
   | `DatasetResource.scala` | Before | After |
   | --- | --- | --- |
   | lines | 212/290 (73.10 %) | **231/290 (79.66 %)** |
   | methods of the `DatasetResource` class | 33/56 | **39/56** |
   
   The six newly-covered methods are exactly the six the issue names.
   
   - **`toggleDatasetPublicity`** — called twice so the assertion pins the 
*flip*
     rather than a one-way set, once as the owner and once as a non-owner 
holding
     WRITE; refused for a caller holding only READ.
   - **`toggleDatasetDownloadable`** — same flip assertion for the owner, plus 
the
     rejection. Note the issue describes this as "same shape" as the publicity
     toggle, but the code differs: this one is guarded by `userOwnDataset` and
     throws `"Only dataset owners can modify download permissions"`, so a 
non-owner
     with WRITE access is refused here while the publicity toggle accepts them. 
The
     test asserts that difference rather than the issue's description.
   - **`updateDatasetDescription`** — persisted description re-read through the 
DAO,
     and the write-access rejection with the old value left intact.
   - **`getPublicDatasetVersionList`** / **`fetchDatasetVersions`** — versions 
of a
     public dataset returned newest-first, alongside a second public dataset 
whose
     versions must not leak in; the empty case; and the `ForbiddenException` 
for a
     private dataset.
   - **`retrieveOwners`** — one email per distinct owner, with two datasets 
sharing an
     owner (so the `selectDistinct` collapses them) and a fourth owner whose 
dataset
     is not granted to the caller; plus the empty result for a user with no 
access.
   
   Two determinism notes, both called for by the issue: the version rows are 
seeded
   with explicit `creation_time` values, because the endpoint orders by that 
column
   and its default would stamp every row inserted in one test identically; and
   `retrieveOwners` is driven by a user created inside the test, since the 
shared
   session users accumulate access rows from other tests and reusing one would 
make
   the result depend on test order. No production code was changed.
   
   ### Any related issues, documentation, discussions?
   
   Closes #7876.
   
   ### How was this PR tested?
   
   ```
   sbt "FileService/Test/scalafmtCheck" "FileService/Test/scalafix --check" \
       "FileService/testOnly *DatasetResourceSpec"
   ```
   
   142 tests in the suite, all passing (130 before, 12 new); `scalafmtCheck` and
   `scalafix --check` clean. `sbt FileService/jacoco` runs the whole module 
green at
   310 tests and produced the numbers above. Failure path verified by breaking 
one
   assertion in each of the 12 new tests: 12 failed / 0 succeeded, sbt exited
   non-zero, then restored to green.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 5)
   


-- 
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