Skip to content

Expand Database module integration coverage across DB, ORM, migration, schema, seeder, and console contracts#109

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

Expand Database module integration coverage across DB, ORM, migration, schema, seeder, and console contracts#109
Copilot wants to merge 4 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 query builder (facades.DB()), ORM (facades.Orm()), and related database modules (migration, schema, seeder, console). The goal is broader behavioral coverage in tests/feature/db_test.go, tests/feature/orm_test.go, and tests/feature/migration_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
    • Added additional query-builder flow coverage:
      • UpdateOrInsert
      • Pluck
      • Value
  • 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
    • Added FirstOrNew flow:
      • existing record is returned when present
      • unsaved model is initialized when missing
    • Added ORM transaction coverage:
      • rollback on callback error
      • commit on success
  • Migration/Schema/Seeder/Console coverage (tests/feature/migration_test.go)

    • Added schema inspector coverage:
      • HasTable, HasColumn, HasColumns
      • GetColumnListing, GetTableListing, GetIndexes
    • Added database console/seeder integration coverage:
      • migrate:status
      • db:seed
      • db:wipe
      • migrate
      • schema-state assertions before/after command execution
  • 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
Co-authored-by: hwbrzzl <24771476+hwbrzzl@users.noreply.github.com>
Copy link
Author

Copilot AI commented Mar 15, 2026

@copilot you are missing some modules as shown below:

https://github.com/goravel/framework/tree/master/database/migration
...

Added follow-up coverage in commit f099470.

It now includes missing database modules you listed:

  • migration/schema: new TestSchemaInspectors in tests/feature/migration_test.go
  • seeder/console: new TestSeederAndDatabaseConsoleCommands validating migrate:status, db:seed, db:wipe, and migrate

I also expanded DB/ORM coverage further:

  • DB: TestUpdateOrInsertAndPluck (update-or-insert, pluck, value)
  • ORM: TestFirstOrNew and TestTransaction (rollback/commit semantics)

Validated with:

  • go test ./tests/feature -run 'TestDBTestSuite|TestOrmTestSuite|TestMigrationTestSuite' -v
  • go test ./tests/feature -run TestDBDrivers -v

Copilot AI changed the title Expand Database module integration coverage across DB and ORM contracts Expand Database module integration coverage across DB, ORM, migration, schema, seeder, and console contracts Mar 15, 2026
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