Skip to content

Commit 82ffc08

Browse files
authored
Merge pull request #3801 from jaredmoo/create_db_sample_name
New-AzureRmSqlDatabase -SampleName
2 parents 2a5d1fc + f66c578 commit 82ffc08

19 files changed

+27581
-118
lines changed

src/ResourceManager/Sql/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Added -SampleName parameter to New-AzureRmSqlDatabase
2122

2223
## Version 2.8.0
2324
* Bug fixes on Azure Failover Group Cmdlets
2425
- Fix for operation polling
2526
- Fix GracePeriodWithDataLossHour value when setting FailoverPolicy to Manual
2627
- Adding obsolete warnings to upcoming parameter changes.
28+
2729
## Version 2.7.0
2830
* Bug fix - Auditing and Threat Detection cmdlets now return a meangfull error instead of null refernce error.
2931
* Updating Transparent Data Encryption (TDE) with Bring Your Own Key (BYOK) support cmdlets for updated API.

src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@
558558
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCreateV2.json">
559559
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
560560
</None>
561+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCreateWithSampleName.json">
562+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
563+
</None>
561564
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseGet.json">
562565
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
563566
</None>

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseCrudTests.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.ScenarioTest.Mocks;
1516
using Microsoft.Azure.Commands.ScenarioTest.SqlTests;
17+
using Microsoft.Azure.Management.Sql;
1618
using Microsoft.Azure.ServiceManagemenet.Common.Models;
1719
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1820
using Xunit;
@@ -22,9 +24,17 @@ namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
2224
{
2325
public class DatabaseCrudTests : SqlTestsBase
2426
{
25-
public DatabaseCrudTests(ITestOutputHelper output)
27+
public DatabaseCrudTests(ITestOutputHelper output) : base(output)
2628
{
27-
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
29+
}
30+
31+
protected override void SetupManagementClients(Rest.ClientRuntime.Azure.TestFramework.MockContext context)
32+
{
33+
// Only SqlClient is needed.
34+
var sqlClient = GetSqlClient(context);
35+
var resourcesClient = GetResourcesClient();
36+
var authorizationClient = GetAuthorizationManagementClient();
37+
helper.SetupSomeOfManagementClients(sqlClient, resourcesClient, authorizationClient);
2838
}
2939

3040
[Fact]
@@ -34,6 +44,13 @@ public void TestDatabaseCreate()
3444
RunPowerShellTest("Test-CreateDatabase");
3545
}
3646

47+
[Fact]
48+
[Trait(Category.AcceptanceType, Category.CheckIn)]
49+
public void TestDatabaseCreateWithSampleName()
50+
{
51+
RunPowerShellTest("Test-CreateDatabaseWithSampleName");
52+
}
53+
3754
[Fact]
3855
[Trait(Category.AcceptanceType, Category.CheckIn)]
3956
public void TestDatabaseUpdate()

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseCrudTests.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,39 @@ function Test-CreateDatabaseInternal ($serverVersion, $location = "Japan East")
107107
}
108108
}
109109

110+
<#
111+
.SYNOPSIS
112+
Tests creating a database with sample name.
113+
#>
114+
function Test-CreateDatabaseWithSampleName
115+
{
116+
# Setup
117+
$rg = Create-ResourceGroupForTest
118+
try
119+
{
120+
$server = Create-ServerForTest $rg
121+
122+
# Create with samplename
123+
$databaseName = Get-DatabaseName
124+
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
125+
-DatabaseName $databaseName -SampleName "AdventureWorksLT" -RequestedServiceObjectiveName Basic `
126+
-Tags @{"tag_key"="tag_value"}
127+
Assert-AreEqual $db.DatabaseName $databaseName
128+
Assert-AreEqual $db.CurrentServiceObjectiveName Basic
129+
Assert-NotNull $db.MaxSizeBytes
130+
Assert-NotNull $db.Edition
131+
Assert-NotNull $db.CurrentServiceObjectiveName
132+
Assert-NotNull $db.CollationName
133+
Assert-NotNull $db.Tags
134+
Assert-AreEqual True $db.Tags.ContainsKey("tag_key")
135+
Assert-AreEqual "tag_value" $db.Tags["tag_key"]
136+
}
137+
finally
138+
{
139+
Remove-ResourceGroupForTest $rg
140+
}
141+
}
142+
110143
<#
111144
.SYNOPSIS
112145
Tests updating a database

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/SqlTestsBase.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
using System;
2727
using System.Collections.Generic;
2828
using System.Linq;
29+
using Microsoft.Azure.ServiceManagemenet.Common.Models;
30+
using Xunit.Abstractions;
2931
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;
3032

3133
namespace Microsoft.Azure.Commands.ScenarioTest.SqlTests
@@ -46,6 +48,15 @@ protected SqlTestsBase()
4648
helper = new SqlEvnSetupHelper();
4749
}
4850

51+
protected SqlTestsBase(ITestOutputHelper output)
52+
{
53+
helper = new SqlEvnSetupHelper();
54+
55+
XunitTracingInterceptor tracer = new XunitTracingInterceptor(output);
56+
XunitTracingInterceptor.AddToContext(tracer);
57+
helper.TracingInterceptor = tracer;
58+
}
59+
4960
protected virtual void SetupManagementClients(RestTestFramework.MockContext context)
5061
{
5162
var sqlClient = GetSqlClient(context);

0 commit comments

Comments
 (0)