-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sql trigger test for different data types (#876)
* add productcolumntypestriggertest * try running only csharp * try running js * comment out column values check temporarily * skip date and byte checks * fix build error * skip byte check * remove date/time, add back binary * fix build error * remove only binary check * remove only nchar and nvarchar * check equality of nchar and nvarchar * fix tests * change nchar to test
- Loading branch information
1 parent
1c0b9dc
commit 02dca71
Showing
13 changed files
with
285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using DotnetIsolatedTests.Common; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Azure.Functions.Worker.Extensions.Sql; | ||
|
||
namespace DotnetIsolatedTests | ||
{ | ||
public static class ProductsColumnTypesTrigger | ||
{ | ||
/// <summary> | ||
/// Simple trigger function used to verify different column types are serialized correctly. | ||
/// </summary> | ||
[Function(nameof(ProductsColumnTypesTrigger))] | ||
public static void Run( | ||
[SqlTrigger("[dbo].[ProductsColumnTypes]", "SqlConnectionString")] | ||
IReadOnlyList<SqlChange<ProductColumnTypes>> changes, | ||
FunctionContext context) | ||
{ | ||
ILogger logger = context.GetLogger("ProductsColumnTypesTrigger"); | ||
logger.LogInformation("SQL Changes: " + Utils.JsonSerializeObject(changes)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
test/Integration/test-csharp/ProductsColumnTypesTrigger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Common; | ||
using Microsoft.Extensions.Logging; | ||
|
||
|
||
namespace Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Integration | ||
{ | ||
public static class ProductsColumnTypesTrigger | ||
{ | ||
/// <summary> | ||
/// Simple trigger function used to verify different column types are serialized correctly. | ||
/// </summary> | ||
[FunctionName(nameof(ProductsColumnTypesTrigger))] | ||
public static void Run( | ||
[SqlTrigger("[dbo].[ProductsColumnTypes]", "SqlConnectionString")] | ||
IReadOnlyList<SqlChange<ProductColumnTypes>> changes, | ||
ILogger logger) | ||
{ | ||
logger.LogInformation("SQL Changes: " + Utils.JsonSerializeObject(changes)); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/Integration/test-csx/ProductsColumnTypesTrigger/function.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "changes", | ||
"type": "sqlTrigger", | ||
"direction": "in", | ||
"tableName": "dbo.ProductsColumnTypes", | ||
"connectionStringSetting": "SqlConnectionString" | ||
} | ||
], | ||
"disabled": false | ||
} |
14 changes: 14 additions & 0 deletions
14
test/Integration/test-csx/ProductsColumnTypesTrigger/run.csx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#load "../Common/Product.csx" | ||
#r "Newtonsoft.Json" | ||
#r "Microsoft.Azure.WebJobs.Extensions.Sql" | ||
|
||
using System.Net; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Primitives; | ||
using Newtonsoft.Json; | ||
using Microsoft.Azure.WebJobs.Extensions.Sql; | ||
|
||
public static void Run(IReadOnlyList<SqlChange<ProductColumnTypes>> changes, ILogger log) | ||
{ | ||
log.LogInformation("SQL Changes: " + Microsoft.Azure.WebJobs.Extensions.Sql.Utils.JsonSerializeObject(changes)); | ||
} |
36 changes: 36 additions & 0 deletions
36
.../Integration/test-java/src/main/java/com/function/Common/SqlChangeProductColumnTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.function.Common; | ||
|
||
public class SqlChangeProductColumnTypes { | ||
private SqlChangeOperation Operation; | ||
private ProductColumnTypes Item; | ||
|
||
public SqlChangeProductColumnTypes() { | ||
} | ||
|
||
public SqlChangeProductColumnTypes(SqlChangeOperation operation, ProductColumnTypes item) { | ||
this.Operation = operation; | ||
this.Item = item; | ||
} | ||
|
||
public SqlChangeOperation getOperation() { | ||
return Operation; | ||
} | ||
|
||
public void setOperation(SqlChangeOperation operation) { | ||
this.Operation = operation; | ||
} | ||
|
||
public ProductColumnTypes getItem() { | ||
return Item; | ||
} | ||
|
||
public void setItem(ProductColumnTypes item) { | ||
this.Item = item; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
test/Integration/test-java/src/main/java/com/function/ProductsColumnTypesTrigger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.function; | ||
|
||
import com.function.Common.SqlChangeProductColumnTypes; | ||
import com.google.gson.Gson; | ||
import com.microsoft.azure.functions.ExecutionContext; | ||
import com.microsoft.azure.functions.annotation.FunctionName; | ||
import com.microsoft.azure.functions.sql.annotation.SQLTrigger; | ||
|
||
import java.util.logging.Level; | ||
|
||
public class ProductsColumnTypesTrigger { | ||
@FunctionName("ProductsColumnTypesTrigger") | ||
public void run( | ||
@SQLTrigger( | ||
name = "changes", | ||
tableName = "[dbo].[ProductsColumnTypes]", | ||
connectionStringSetting = "SqlConnectionString") | ||
SqlChangeProductColumnTypes[] changes, | ||
ExecutionContext context) throws Exception { | ||
|
||
context.getLogger().log(Level.INFO, "SQL Changes: " + new Gson().toJson(changes)); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/Integration/test-js/ProductsColumnTypesTrigger/function.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "changes", | ||
"type": "sqlTrigger", | ||
"direction": "in", | ||
"tableName": "dbo.ProductsColumnTypes", | ||
"connectionStringSetting": "SqlConnectionString" | ||
} | ||
], | ||
"disabled": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
module.exports = async function (context, changes) { | ||
context.log(`SQL Changes: ${JSON.stringify(changes)}`) | ||
} |
12 changes: 12 additions & 0 deletions
12
test/Integration/test-powershell/ProductsColumnTypesTrigger/function.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "changes", | ||
"type": "sqlTrigger", | ||
"direction": "in", | ||
"tableName": "dbo.ProductsColumnTypes", | ||
"connectionStringSetting": "SqlConnectionString" | ||
} | ||
], | ||
"disabled": false | ||
} |
9 changes: 9 additions & 0 deletions
9
test/Integration/test-powershell/ProductsColumnTypesTrigger/run.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using namespace System.Net | ||
|
||
param($changes) | ||
|
||
$changesJson = $changes | ConvertTo-Json -Compress -AsArray | ||
Write-Host "SQL Changes: $changesJson" |
7 changes: 7 additions & 0 deletions
7
test/Integration/test-python/ProductsColumnTypesTrigger/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import logging | ||
|
||
def main(changes): | ||
logging.info("SQL Changes: %s", changes) |
12 changes: 12 additions & 0 deletions
12
test/Integration/test-python/ProductsColumnTypesTrigger/function.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "changes", | ||
"type": "sqlTrigger", | ||
"direction": "in", | ||
"tableName": "dbo.ProductsColumnTypes", | ||
"connectionStringSetting": "SqlConnectionString" | ||
} | ||
], | ||
"disabled": false | ||
} |