Skip to content

refactor: integrate multi-database test support and remove redundant tests#282

Merged
Ahoo-Wang merged 26 commits into
masterfrom
it
May 14, 2026
Merged

refactor: integrate multi-database test support and remove redundant tests#282
Ahoo-Wang merged 26 commits into
masterfrom
it

Conversation

@Ahoo-Wang
Copy link
Copy Markdown
Member

Summary

  • Add multi-database integration test support for MySQL, PostgreSQL, SQL Server, and SQLite
  • Implement base test class + DB-specific subclass pattern using xUnit Collections
  • Remove redundant tests already covered by unit tests (Tags/, Cache/, Deserializer/*, etc.)
  • Add per-DB XML config files and init SQL scripts
  • Enable $ portable parameter prefix with <Env> tags for DB-specific SQL
  • Fix SmartSqlBuilder.UseDatabase() to allow chaining with UseXmlConfig()
  • Fix SQLite compatibility issues (TimeSpan, last_insert_rowid, in-memory DB sharing)
  • Add test fixtures for PostgreSQL and SQL Server using Testcontainers

Breaking Changes

  • Removed deprecated test fixtures and redundant test classes

Test Plan

  • Unit tests pass (1690/1690)
  • SQLite integration tests pass (42/42)
  • MySQL, PostgreSQL, SQL Server integration tests pass (requires Docker)

Ahoo-Wang added 16 commits May 14, 2026 13:28
Design for restructuring integration tests:
- Remove unit-test-overlapping tests (Tags, Cache, Deserializers, etc.)
- Add multi-DB support: MySQL 8, PostgreSQL 16, SQL Server 2022, SQLite
- Use abstract base classes + DB-specific subclasses pattern
- Use <Env> tags for DB-specific SQL fragments in maps
- One init script per database
…ity issues

- Add UseDatabase() method to SmartSqlBuilder for overriding DB provider
  and connection string independently from XML config (allows UseXmlConfig()
  + UseDatabase() chaining)
- Fix SQLite in-memory DB sharing: use named memory DB
  (Data Source=InMemory;Mode=Memory;Cache=Shared) so Write and Read
  connections share the same database
- Fix TimeSpanAnyTypeHandler: add string parsing for SQLite TIME columns
  that return 'HH:MM:SS' format
- Fix SQLite SelectAutoIncrement: add ';Select last_insert_rowid();'
  to enable CUD auto-generated InsertReturnId
- Fix DbSessionTestBase: use @ prefix for SQLite and SQL Server RealSql
  (matches SqlParamAnalyzer's dbPrefix) instead of $ portable prefix
- Add SmartSqlMapConfig.Sqlite.xml with specific map files and
  read replica datasources
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.86%. Comparing base (d9a68af) to head (80d09c7).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #282      +/-   ##
==========================================
+ Coverage   72.76%   72.86%   +0.10%     
==========================================
  Files         314      314              
  Lines        7164     7180      +16     
  Branches      999     1007       +8     
==========================================
+ Hits         5213     5232      +19     
+ Misses       1719     1717       -2     
+ Partials      232      231       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Add ConnectionString property to SQL Server config
- Use specific Map files instead of Maps directory to avoid
  loading T_Entity.xml (references non-existent table)
- Disable cache for PostgreSQL and SQL Server (no Redis in CI)
Ahoo-Wang added 9 commits May 14, 2026 15:50
- Create SmartSqlMapConfig.MySql.xml with disabled cache
- Update MySqlFixture to use the new config
- Add missing using statement for ResourceType
- Skip MySqlRedisCacheTests and MySqlUsedCacheRepositoryTests
- These require Redis container which CI environment lacks
- Set IsCacheEnabled=false in default SmartSqlMapConfig.xml
- Fix DI tests to use UseCache(false) to prevent Redis connection
- Fix PostgreSQL init SQL: remove double quotes to match lowercase
  table name resolution
- Use explicit Map file list instead of Maps directory to exclude
  RedisCache.xml, FifoCache.xml, and LruCache.xml
- Add TagTest.xml for DI tests
- Fix DbSessionTestBase to use ? prefix for MySQL (matches DbProvider)
- Use @ prefix for SQLite and SQL Server
- Change MySQL fixture alias to GlobalSmartSql to match
  ColumnAnnotationEntity's hardcoded alias reference
- Skip PostgreSQL (backtick quoting incompatibility) and SQL Server
  (DateTime overflow) in CI until Maps XML is updated with <Env> tags
…ypeHandler

- Test UseDatabase with valid and invalid provider names
- Test UseDatabase connection string override with XML config
- Test UseDatabase read datasource connection string override
- Test TimeSpanAnyTypeHandler for TimeSpan, Int64, string, and default
  conversion paths
@Ahoo-Wang Ahoo-Wang merged commit 00d4df2 into master May 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant