-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
2 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
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
72 changes: 72 additions & 0 deletions
72
code/DeltaKustoUnitTest/CommandParsing/Policies/AlterIngestionTimePolicyTest.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,72 @@ | ||
using DeltaKustoLib.CommandModel; | ||
using DeltaKustoLib.CommandModel.Policies; | ||
using System; | ||
using System.Linq; | ||
using System.Text.Json; | ||
using Xunit; | ||
|
||
namespace DeltaKustoUnitTest.CommandParsing.Policies | ||
{ | ||
public class AlterIngestionTimePolicyTest : ParsingTestBase | ||
{ | ||
[Fact] | ||
public void SimpleTable() | ||
{ | ||
TestIngestionTimePolicy("A"); | ||
} | ||
|
||
[Fact] | ||
public void FunkyTable() | ||
{ | ||
TestIngestionTimePolicy("['A- 1']"); | ||
} | ||
|
||
[Fact] | ||
public void DbComposedTableName() | ||
{ | ||
var command = ParseOneCommand( | ||
".alter table mydb.mytable policy auto_delete" | ||
+ "@'{\"ExpiryDate\":\"2030-02-01\"}'"); | ||
|
||
Assert.IsType<AlterAutoDeletePolicyCommand>(command); | ||
|
||
var realCommand = (AlterAutoDeletePolicyCommand)command; | ||
|
||
Assert.Equal("mytable", realCommand.TableName.Name); | ||
} | ||
|
||
[Fact] | ||
public void ClusterComposedTableName() | ||
{ | ||
var command = ParseOneCommand( | ||
".alter table mycluster.['my db'].mytable policy auto_delete " | ||
+ "@'{\"ExpiryDate\":\"2031-02-01\"}'"); | ||
|
||
Assert.IsType<AlterAutoDeletePolicyCommand>(command); | ||
|
||
var realCommand = (AlterAutoDeletePolicyCommand)command; | ||
|
||
Assert.Equal("mytable", realCommand.TableName.Name); | ||
} | ||
|
||
private void TestIngestionTimePolicy(string tableName) | ||
{ | ||
TestIngestionTimePolicy(tableName, true); | ||
TestIngestionTimePolicy(tableName, false); | ||
} | ||
|
||
private void TestIngestionTimePolicy(string tableName, bool isEnabled) | ||
{ | ||
var commandText = $@" | ||
.alter table {tableName} policy ingestiontime {isEnabled.ToString().ToLower()}"; | ||
var command = ParseOneCommand(commandText); | ||
|
||
Assert.IsType<AlterIngestionTimePolicyCommand>(command); | ||
|
||
var realCommand = (AlterIngestionTimePolicyCommand)command; | ||
|
||
Assert.Equal(tableName, realCommand.TableName.Name); | ||
Assert.Equal(isEnabled, realCommand.IsEnabled); | ||
} | ||
} | ||
} |