Skip to content

Expand Database module integration coverage across DB and ORM contracts#109

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/add-full-tests-database-module
Draft

Expand Database module integration coverage across DB and ORM contracts#109
Copilot wants to merge 3 commits intomasterfrom
copilot/add-full-tests-database-module

Conversation

Copy link

Copilot AI commented Mar 14, 2026

This PR extends goravel/example database integration tests to cover missing contract-level behaviors in both query builder (facades.DB()) and ORM (facades.Orm()), beyond the existing basic CRUD and restore cases. The goal is broader behavioral coverage in tests/feature/db_test.go and tests/feature/orm_test.go so framework regressions surface via failing tests.

  • DB contract coverage (tests/feature/db_test.go)

    • Added transaction semantics coverage:
      • rollback path does not persist inserted rows
      • commit path persists inserted rows
    • Added query helper coverage:
      • Count, Exists, DoesntExist, WhereNotNull(...).Count()
      • multi-row insert + RowsAffected assertions
    • Added error-path coverage:
      • FirstOr callback execution only on miss
      • callback error propagation
      • FindOrFail failure on missing row
  • ORM contract coverage (tests/feature/orm_test.go)

    • Added FirstOrCreate flow:
      • create-on-miss
      • find-on-hit without duplicate row creation
    • Added UpdateOrCreate flow:
      • create-on-miss
      • update-on-hit with stable identity and single-row invariant
  • Cross-driver behavior

    • New test cases are implemented in existing suites so they run under the repository’s multi-driver database test harness (postgres/mysql/sqlserver), consistent with current feature test structure.
func (s *DBTestSuite) TestTransaction() {
	tx, _ := facades.DB().BeginTransaction()
	_, _ = tx.Table("users").Insert(map[string]any{"name": "rollback"})
	_ = tx.Rollback()

	exists, _ := facades.DB().Table("users").Where("name", "rollback").Exists()
	s.False(exists) // rollback should not persist data
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Add full tests for the Database module</issue_title>
<issue_description>### Before feedback (在反馈之前)

  • There are no features that I want to submit in Issues (当前 Issues 中没有我将要提交的新功能)

Describe Feature (描述功能)

Before feedback (在反馈之前)

  • There are no features that I want to submit in Issues (当前 Issues 中没有我将要提交的新功能)

Describe Feature (描述功能)

We want to add integration tests for goravel/framework's features to ensure they work as expected.

  1. Add full tests for the Database module in goravel/example based on the interface: https://github.com/goravel/framework/tree/master/contracts/database.
  2. The tests can be added in https://github.com/goravel/example/tree/master/tests/feature/db_test.go and orm_test.go. There are some existing cases, try to find missing flows. Feel free to add a controller in https://github.com/goravel/example/tree/master/app/http/controllers if a request is required.
  3. Let tests fail if there are bugs in the module.
  4. Create a branch for the PR based on the master branch, and merge the PR to the master branch.</issue_description>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI and others added 2 commits March 14, 2026 14:24
Co-authored-by: hwbrzzl <24771476+hwbrzzl@users.noreply.github.com>
Co-authored-by: hwbrzzl <24771476+hwbrzzl@users.noreply.github.com>
Copilot AI changed the title [WIP] Add full tests for the Database module Expand Database module integration coverage across DB and ORM contracts Mar 14, 2026
Copilot AI requested a review from hwbrzzl March 14, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants