Open Closed

Unit tests are getting failing because Sqlite cannot seed database because of some sql statement which are valid for sql server but not for sqlite #5710


User avatar
0
sukhdeep.dhillon created
  • ABP Framework version: v6.0.2
  • UI Type: Angular / MVC / Blazor WASM / Blazor Server
  • Database System: EF Core (SQL Server)

Hi, I have bunch of sql insert statements store in .sql file. This file is being loaded and executed by the data seeder. when DbMigrator runs and it successfully populated the database. but when I run unit tests, all are getting failed because when sqlite seeds the database for tests. it loads that .sql file I'm getting the following error

because IF EXISTS statement doesn't exist in sqllite but its fine with sql server.

how can I handle this situation. plus, if I don't want unit tests to seed specific data how can I handle that

following is the screenshot of .sql file for your reference


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can convert your sql server file to SQLite. Then use SQLite statements in unit tests.

  • User Avatar
    0
    sukhdeep.dhillon created

    Could you please give me any code example. plus, what if I don't want to seed this data in unit tests, how can I remove this seeding file while running unit tests.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can exec your sql on

    https://github.com/abpframework/abp/blob/dev/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs#L102-L104

    You can remove your Contributorfrom AbpDataSeedOptions

    services.Configure<AbpDataSeedOptions>(options =>
    {
        options.Contributors.Remove...
    });
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11