Skip to content

Add no-DB unit tests for the dashboard search query tier #7115

Description

@aglinxinyuan

Task Summary

FulltextSearchQueryUtilsSpec is the only spec in amber/src/main/scala/org/apache/texera/web/resource/dashboard/. It also demonstrates that this tier does not need a database to test: a dialect-only DSL.using(SQLDialect.POSTGRES) context renders jOOQ Condition/Field objects with no connection, and ctx.newRecord(...) builds records purely in memory.

Three members of the tier are connection-free and untested:

  • DashboardResource.getOrderFields (22 missed lines in the file) — public and pure. It regex-matches orderBy against (Name|CreateTime|EditTime|ExecutionTime)(Asc|Desc). Existing coverage is only incidental, via WorkflowResourceSpec, and reaches NameAsc/NameDesc, ExecutionTimeAsc/Desc and EditTime through the default. CreateTimeAsc/CreateTimeDesc and the non-matching fall-through are unreached. The asc/desc asymmetry is also worth pinning: Desc emits desc nulls last while Asc emits a bare asc, and that asymmetry is what makes the observable behaviour symmetric, since Postgres defaults to NULLS LAST for ASC and NULLS FIRST for DESC. Separately, searchAllResources with an unrecognised resourceType throws IllegalArgumentException before any query is constructed, so that path needs no database either.
  • WorkflowSearchQueryBuilder.toEntryImpl and mappedResourceSchema (7 missed) — reachable because this object drops the trait's protected, unlike DatasetSearchQueryBuilder whose five members are all override protected (Scala protected grants no same-package access, so those are not callable from a spec). toEntryImpl is pure record-to-DTO mapping: the projects aggregate is looked up by structural jOOQ Field equality, the comma-joined value is split into Integers, a NULL privilege degrades to NONE, and an ownership flag compares uids.
  • UnifiedResourceSchema.apply (5 missed) — 24 default-argument Fields, plus a keep-first de-duplication behind allFields that collapses repeated originals.

translateRecord, resultsOwnersInfo, searchAllPublicResourceCall, constructQuery and every fetch path route through SqlServer.getInstance().createDSLContext() and are out of scope for a no-DB spec.

Note for whoever picks this up: FulltextSearchQueryUtils.usePgroonga is a JVM-global var that DatasetResourceSpec and WorkflowResourceSpec both set to false in beforeAll and never restore, and amber's suites run concurrently in one JVM. New specs here should neither depend on its default nor mutate it.

Task Type

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions