mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-29 09:35:38 -05:00
Check if Azure Function method is async before adding output binding (#1297)
* check async before adding output binding * nit
This commit is contained in:
@@ -76,6 +76,37 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AzureFunctions
|
||||
Assert.AreEqual(expectedFileText, actualFileText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify output binding gets added for an async method
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void AddSqlOutputBindingAsync()
|
||||
{
|
||||
// copy the original file because the output binding will be inserted into the file
|
||||
string originalFile = Path.Join(testAzureFunctionsFolder, "AzureFunctionsNoBindings.cs");
|
||||
string testFile = Path.Join(Path.GetTempPath(), $"InsertSqlOutputBindingAsync-{DateTime.Now.ToString("yyyy - dd - MM--HH - mm - ss")}.cs");
|
||||
File.Copy(originalFile, testFile, true);
|
||||
|
||||
AddSqlBindingParams parameters = new AddSqlBindingParams
|
||||
{
|
||||
bindingType = BindingType.output,
|
||||
filePath = testFile,
|
||||
functionName = "NewArtists_post",
|
||||
objectName = "[dbo].[table1]",
|
||||
connectionStringSetting = "SqlConnectionString"
|
||||
};
|
||||
|
||||
AddSqlBindingOperation operation = new AddSqlBindingOperation(parameters);
|
||||
ResultStatus result = operation.AddBinding();
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.IsNull(result.ErrorMessage);
|
||||
|
||||
string expectedFileText = File.ReadAllText(Path.Join(testAzureFunctionsFolder, "AzureFunctionsOutputBindingAsync.cs"));
|
||||
string actualFileText = File.ReadAllText(testFile);
|
||||
Assert.AreEqual(expectedFileText, actualFileText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify what happens when specified azure function isn't found
|
||||
/// </summary>
|
||||
@@ -150,9 +181,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.AzureFunctions
|
||||
|
||||
Assert.True(result.Success);
|
||||
Assert.Null(result.ErrorMessage);
|
||||
Assert.AreEqual(2, result.azureFunctions.Length);
|
||||
Assert.AreEqual(3, result.azureFunctions.Length);
|
||||
Assert.AreEqual(result.azureFunctions[0], "GetArtists_get");
|
||||
Assert.AreEqual(result.azureFunctions[1], "NewArtist_post");
|
||||
Assert.AreEqual(result.azureFunctions[2], "NewArtists_post");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user