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

restore point create and delete API missed test added #4168

Merged
merged 1 commit into from
Mar 29, 2018
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
70 changes: 70 additions & 0 deletions src/SDKs/SqlManagement/Sql.Tests/DatabaseRestoreScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,75 @@ public void TestDatabaseGeoRecovery()
});
}
}

[Fact]
public void TestDatabaseRestorePoint()
{
using (SqlManagementTestContext context = new SqlManagementTestContext(this))
{
ResourceGroup resourceGroup = context.CreateResourceGroup();
Server server = context.CreateServer(resourceGroup);
SqlManagementClient sqlClient = context.GetClient<SqlManagementClient>();
string restoreLabel = "restorePointLabel";

// Create database with only required parameters
var db = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, SqlManagementTestUtilities.GenerateName(),
new Database
{
Location = server.Location,
Edition = DatabaseEdition.DataWarehouse,
RequestedServiceObjectiveName = ServiceObjectiveName.DW100
});
Assert.NotNull(db);

CreateDatabaseRestorePointDefinition restoreDefinition = new CreateDatabaseRestorePointDefinition { RestorePointLabel = restoreLabel };

RestorePoint postResponse = sqlClient.RestorePoints.Create(
resourceGroup.Name,
server.Name,
db.Name,
restoreDefinition);

Assert.True(postResponse.RestorePointType == RestorePointType.DISCRETE);
Assert.True(postResponse.RestorePointLabel == restoreLabel);
Assert.True(!string.IsNullOrWhiteSpace(postResponse.RestorePointCreationDate.ToString()));

IEnumerable<RestorePoint> listResponse =
sqlClient.RestorePoints.ListByDatabase(
resourceGroup.Name,
server.Name,
db.Name);

IEnumerable<RestorePoint> restorePointList = listResponse.ToList<RestorePoint>();

Assert.True(restorePointList.Any());

RestorePoint getResponse =
sqlClient.RestorePoints.Get(
resourceGroup.Name,
server.Name,
db.Name,
postResponse.Name);

Assert.True(getResponse.RestorePointType == RestorePointType.DISCRETE);
Assert.True(!string.IsNullOrWhiteSpace(getResponse.RestorePointCreationDate.ToString()));
Assert.True(getResponse.Name == postResponse.Name);

sqlClient.RestorePoints.Delete(
resourceGroup.Name,
server.Name,
db.Name,
getResponse.Name);

IEnumerable<RestorePoint> listResponseAfterDelete =
sqlClient.RestorePoints.ListByDatabase(
resourceGroup.Name,
server.Name,
db.Name);

Assert.True(!listResponseAfterDelete.Any()
|| !listResponseAfterDelete.Where(x => x.Name == postResponse.Name).Any());
}
}
}
}
Loading