Skip to content

Commit 80ef52c

Browse files
Move setup scripts into separate folders (#197)
* Move setup scripts into separate folders * copy all files * Add debug logging * Fix typo
1 parent 50aa037 commit 80ef52c

File tree

10 files changed

+16
-7
lines changed

10 files changed

+16
-7
lines changed
File renamed without changes.

samples/Microsoft.Azure.WebJobs.Extensions.Sql.Samples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<None Update="Database\*.sql">
17+
<None Update="Database\**\*.sql">
1818
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
1919
</None>
2020
<None Update="host.json">

test/Common/TestUtils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static int ExecuteNonQuery(
5959

6060
cmd.CommandText = commandText;
6161
cmd.CommandType = CommandType.Text;
62-
62+
Console.WriteLine($"Executing non-query ${commandText}");
6363
return cmd.ExecuteNonQuery();
6464
}
6565
catch (Exception ex)
@@ -102,6 +102,7 @@ public static object ExecuteScalar(
102102
{
103103
cmd.CommandText = commandText;
104104
cmd.CommandType = CommandType.Text;
105+
Console.WriteLine($"Executing scalar ${commandText}");
105106
return cmd.ExecuteScalar();
106107
}
107108
catch (Exception ex)

test/Integration/IntegrationTestBase.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,25 @@ private void SetupDatabase()
119119
this.Connection.Open();
120120

121121
// Create the database definition
122+
// Create these in a specific order since things like views require that their underlying objects have been created already
122123
// Ideally all the sql files would be in a sqlproj and can just be deployed
123-
string databaseScriptsPath = Path.Combine(GetPathToBin(), "Database");
124-
foreach (string file in Directory.EnumerateFiles(databaseScriptsPath, "*.sql"))
125-
{
126-
this.ExecuteNonQuery(File.ReadAllText(file));
127-
}
124+
this.ExecuteAllScriptsInFolder(Path.Combine(GetPathToBin(), "Database", "Tables"));
125+
this.ExecuteAllScriptsInFolder(Path.Combine(GetPathToBin(), "Database", "Views"));
126+
this.ExecuteAllScriptsInFolder(Path.Combine(GetPathToBin(), "Database", "StoredProcedures"));
128127

129128
// Set SqlConnectionString env var for the Function to use
130129
Environment.SetEnvironmentVariable("SqlConnectionString", connectionStringBuilder.ToString());
131130
}
132131

132+
private void ExecuteAllScriptsInFolder(string folder)
133+
{
134+
foreach (string file in Directory.EnumerateFiles(folder, "*.sql"))
135+
{
136+
Console.WriteLine($"Executing script ${file}");
137+
this.ExecuteNonQuery(File.ReadAllText(file));
138+
}
139+
}
140+
133141
/// <summary>
134142
/// This starts the Azurite storage emulator.
135143
/// </summary>

0 commit comments

Comments
 (0)