-
Notifications
You must be signed in to change notification settings - Fork 731
/
NoDeploymentsResourcesRuleTests.cs
61 lines (56 loc) · 1.45 KB
/
NoDeploymentsResourcesRuleTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Bicep.Core.Analyzers.Linter.Rules;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Bicep.Core.UnitTests.Diagnostics.LinterRuleTests;
[TestClass]
public class NoDeploymentsResourcesRuleTests : LinterRuleTestsBase
{
private void CompileAndTest(string text, int expectedDiagnosticCount, Options? options = null)
{
AssertLinterRuleDiagnostics(NoDeploymentsResourcesRule.Code, text, expectedDiagnosticCount, options);
}
[DataRow("""
param name string
param specId string
resource foo 'Microsoft.Resources/deployments@2021-04-01' = {
name: name
properties: {
mode: 'Incremental'
templateLink: {
uri: specId
}
parameters: {}
}
}
""")]
[DataRow("""
param name string
resource foo 'Microsoft.Resources/deployments@2021-04-01' existing = {
name: name
}
""")]
[DataTestMethod]
public void Linter_validation_should_warn_for_nested_deployment_resources(string text)
{
CompileAndTest(text, 1);
}
[DataRow("""
param name string
param location string
resource foo 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
kind: 'AzureCLI'
name: name
properties: {
azCliVersion: 's'
retentionInterval: 's'
}
location: location
}
""")]
[DataTestMethod]
public void Linter_validation_should_not_warn_for_non_deployment_resource_types(string text)
{
CompileAndTest(text, 0);
}
}