Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test coverage for altering check constraints #20877

Merged
merged 1 commit into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/EFCore.Relational.Specification.Tests/MigrationsTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,22 @@ public virtual Task Add_check_constraint_with_name()
// TODO: no scaffolding support for check constraints, https://github.com/aspnet/EntityFrameworkCore/issues/15408
});

[ConditionalFact]
public virtual Task Alter_check_constraint()
=> Test(
builder => builder.Entity(
"People", e =>
{
e.Property<int>("Id");
e.Property<int>("DriverLicense");
}),
builder => builder.Entity("People").HasCheckConstraint("CK_Foo", $"{DelimitIdentifier("DriverLicense")} > 0"),
builder => builder.Entity("People").HasCheckConstraint("CK_Foo", $"{DelimitIdentifier("DriverLicense")} > 1"),
model =>
{
// TODO: no scaffolding support for check constraints, https://github.com/aspnet/EntityFrameworkCore/issues/15408
});

[ConditionalFact]
public virtual Task Drop_check_constraint()
=> Test(
Expand Down
10 changes: 10 additions & 0 deletions test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,16 @@ public override async Task Add_check_constraint_with_name()
@"ALTER TABLE [People] ADD CONSTRAINT [CK_Foo] CHECK ([DriverLicense] > 0);");
}

public override async Task Alter_check_constraint()
{
await base.Alter_check_constraint();

AssertSql(
@"ALTER TABLE [People] DROP CONSTRAINT [CK_Foo];",
//
@"ALTER TABLE [People] ADD CONSTRAINT [CK_Foo] CHECK ([DriverLicense] > 1);");
}

public override async Task Drop_check_constraint()
{
await base.Drop_check_constraint();
Expand Down
4 changes: 4 additions & 0 deletions test/EFCore.Sqlite.FunctionalTests/MigrationsSqliteTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ public override Task Add_check_constraint_with_name()
=> AssertNotSupportedAsync(
base.Add_check_constraint_with_name, SqliteStrings.InvalidMigrationOperation("CreateCheckConstraintOperation"));

public override Task Alter_check_constraint()
=> AssertNotSupportedAsync(
base.Alter_check_constraint, SqliteStrings.InvalidMigrationOperation("DropCheckConstraintOperation"));

public override Task Drop_check_constraint()
=> AssertNotSupportedAsync(base.Drop_check_constraint, SqliteStrings.InvalidMigrationOperation("DropCheckConstraintOperation"));

Expand Down