|
| 1 | +// Copyright (c) Microsoft Corporation. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +using Bicep.Core.UnitTests.Assertions; |
| 5 | +using FluentAssertions; |
| 6 | +using FluentAssertions.Execution; |
| 7 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 8 | + |
| 9 | +namespace Bicep.Cli.IntegrationTests |
| 10 | +{ |
| 11 | + [TestClass] |
| 12 | + public class HelpTests : TestBase |
| 13 | + { |
| 14 | + [TestMethod] |
| 15 | + public async Task Root_Help_ShouldSucceed_WithExpectedOutput() |
| 16 | + { |
| 17 | + var (output, error, result) = await Bicep("--help"); |
| 18 | + |
| 19 | + using (new AssertionScope()) |
| 20 | + { |
| 21 | + result.Should().Be(0); |
| 22 | + error.Should().BeEmpty(); |
| 23 | + output.Should().ContainAll( |
| 24 | + "build", |
| 25 | + "build-params", |
| 26 | + "decompile", |
| 27 | + "decompile-params", |
| 28 | + "format", |
| 29 | + "generate-params", |
| 30 | + "lint", |
| 31 | + "publish", |
| 32 | + "restore", |
| 33 | + "test", |
| 34 | + "--version", |
| 35 | + "--license", |
| 36 | + "--third-party-notices"); |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + [TestMethod] |
| 41 | + public async Task Build_Help_ShouldSucceed_WithExpectedOutput() |
| 42 | + { |
| 43 | + var (output, error, result) = await Bicep("build", "--help"); |
| 44 | + |
| 45 | + using (new AssertionScope()) |
| 46 | + { |
| 47 | + result.Should().Be(0); |
| 48 | + error.Should().BeEmpty(); |
| 49 | + output.Should().ContainAll( |
| 50 | + "build", |
| 51 | + "Builds a .bicep file.", |
| 52 | + "--stdout", |
| 53 | + "--no-restore", |
| 54 | + "--outdir", |
| 55 | + "--outfile", |
| 56 | + "--pattern", |
| 57 | + "--diagnostics-format"); |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + [TestMethod] |
| 62 | + public async Task Test_Help_ShouldSucceed_WithExpectedOutput() |
| 63 | + { |
| 64 | + var (output, error, result) = await Bicep("test", "--help"); |
| 65 | + |
| 66 | + using (new AssertionScope()) |
| 67 | + { |
| 68 | + result.Should().Be(0); |
| 69 | + error.Should().BeEmpty(); |
| 70 | + output.Should().ContainAll( |
| 71 | + "test", |
| 72 | + "Runs tests in a .bicep file.", |
| 73 | + "--no-restore", |
| 74 | + "--diagnostics-format"); |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + [TestMethod] |
| 79 | + public async Task BuildParams_Help_ShouldSucceed_WithExpectedOutput() |
| 80 | + { |
| 81 | + var (output, error, result) = await Bicep("build-params", "--help"); |
| 82 | + |
| 83 | + using (new AssertionScope()) |
| 84 | + { |
| 85 | + result.Should().Be(0); |
| 86 | + error.Should().BeEmpty(); |
| 87 | + output.Should().ContainAll( |
| 88 | + "build-params", |
| 89 | + "Builds a .json file from a .bicepparam file.", |
| 90 | + "--stdout", |
| 91 | + "--no-restore", |
| 92 | + "--outdir", |
| 93 | + "--outfile", |
| 94 | + "--pattern", |
| 95 | + "--bicep-file", |
| 96 | + "--diagnostics-format"); |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + [TestMethod] |
| 101 | + public async Task Format_Help_ShouldSucceed_WithExpectedOutput() |
| 102 | + { |
| 103 | + var (output, error, result) = await Bicep("format", "--help"); |
| 104 | + |
| 105 | + using (new AssertionScope()) |
| 106 | + { |
| 107 | + result.Should().Be(0); |
| 108 | + error.Should().BeEmpty(); |
| 109 | + output.Should().ContainAll( |
| 110 | + "format", |
| 111 | + "Formats a .bicep file.", |
| 112 | + "--stdout", |
| 113 | + "--outdir", |
| 114 | + "--outfile", |
| 115 | + "--pattern", |
| 116 | + "--newline-kind", |
| 117 | + "--indent-kind", |
| 118 | + "--indent-size", |
| 119 | + "--insert-final-newline"); |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + [TestMethod] |
| 124 | + public async Task GenerateParams_Help_ShouldSucceed_WithExpectedOutput() |
| 125 | + { |
| 126 | + var (output, error, result) = await Bicep("generate-params", "--help"); |
| 127 | + |
| 128 | + using (new AssertionScope()) |
| 129 | + { |
| 130 | + result.Should().Be(0); |
| 131 | + error.Should().BeEmpty(); |
| 132 | + output.Should().ContainAll( |
| 133 | + "generate-params", |
| 134 | + "Builds parameters file", |
| 135 | + "--stdout", |
| 136 | + "--no-restore", |
| 137 | + "--outdir", |
| 138 | + "--outfile", |
| 139 | + "--output-format", |
| 140 | + "--include-params"); |
| 141 | + } |
| 142 | + } |
| 143 | + |
| 144 | + [TestMethod] |
| 145 | + public async Task Decompile_Help_ShouldSucceed_WithExpectedOutput() |
| 146 | + { |
| 147 | + var (output, error, result) = await Bicep("decompile", "--help"); |
| 148 | + |
| 149 | + using (new AssertionScope()) |
| 150 | + { |
| 151 | + result.Should().Be(0); |
| 152 | + error.Should().BeEmpty(); |
| 153 | + output.Should().ContainAll( |
| 154 | + "decompile", |
| 155 | + "Attempts to decompile a template .json file to .bicep.", |
| 156 | + "--stdout", |
| 157 | + "--force", |
| 158 | + "--outdir", |
| 159 | + "--outfile"); |
| 160 | + } |
| 161 | + } |
| 162 | + |
| 163 | + [TestMethod] |
| 164 | + public async Task DecompileParams_Help_ShouldSucceed_WithExpectedOutput() |
| 165 | + { |
| 166 | + var (output, error, result) = await Bicep("decompile-params", "--help"); |
| 167 | + |
| 168 | + using (new AssertionScope()) |
| 169 | + { |
| 170 | + result.Should().Be(0); |
| 171 | + error.Should().BeEmpty(); |
| 172 | + output.Should().ContainAll( |
| 173 | + "decompile-params", |
| 174 | + "Attempts to decompile a parameters .json file to .bicepparam.", |
| 175 | + "--stdout", |
| 176 | + "--force", |
| 177 | + "--outdir", |
| 178 | + "--outfile", |
| 179 | + "--bicep-file"); |
| 180 | + } |
| 181 | + } |
| 182 | + |
| 183 | + [TestMethod] |
| 184 | + public async Task Publish_Help_ShouldSucceed_WithExpectedOutput() |
| 185 | + { |
| 186 | + var (output, error, result) = await Bicep("publish", "--help"); |
| 187 | + |
| 188 | + using (new AssertionScope()) |
| 189 | + { |
| 190 | + result.Should().Be(0); |
| 191 | + error.Should().BeEmpty(); |
| 192 | + output.Should().ContainAll( |
| 193 | + "publish", |
| 194 | + "Publishes the .bicep file to the module registry.", |
| 195 | + "--target", |
| 196 | + "--documentation-uri", |
| 197 | + "--no-restore", |
| 198 | + "--force", |
| 199 | + "--with-source"); |
| 200 | + } |
| 201 | + } |
| 202 | + |
| 203 | + [TestMethod] |
| 204 | + public async Task PublishExtension_Help_ShouldSucceed_WithExpectedOutput() |
| 205 | + { |
| 206 | + var (output, error, result) = await Bicep("publish-extension", "--help"); |
| 207 | + |
| 208 | + using (new AssertionScope()) |
| 209 | + { |
| 210 | + result.Should().Be(0); |
| 211 | + error.Should().BeEmpty(); |
| 212 | + output.Should().ContainAll( |
| 213 | + "publish-extension", |
| 214 | + "Publishes a Bicep extension to a registry.", |
| 215 | + "--target", |
| 216 | + "--force", |
| 217 | + "--bin-linux-x64", |
| 218 | + "--bin-win-x64"); |
| 219 | + } |
| 220 | + } |
| 221 | + |
| 222 | + [TestMethod] |
| 223 | + public async Task Restore_Help_ShouldSucceed_WithExpectedOutput() |
| 224 | + { |
| 225 | + var (output, error, result) = await Bicep("restore", "--help"); |
| 226 | + |
| 227 | + using (new AssertionScope()) |
| 228 | + { |
| 229 | + result.Should().Be(0); |
| 230 | + error.Should().BeEmpty(); |
| 231 | + output.Should().ContainAll( |
| 232 | + "restore", |
| 233 | + "Restores external modules", |
| 234 | + "--pattern", |
| 235 | + "--force"); |
| 236 | + } |
| 237 | + } |
| 238 | + |
| 239 | + [TestMethod] |
| 240 | + public async Task Lint_Help_ShouldSucceed_WithExpectedOutput() |
| 241 | + { |
| 242 | + var (output, error, result) = await Bicep("lint", "--help"); |
| 243 | + |
| 244 | + using (new AssertionScope()) |
| 245 | + { |
| 246 | + result.Should().Be(0); |
| 247 | + error.Should().BeEmpty(); |
| 248 | + output.Should().ContainAll( |
| 249 | + "lint", |
| 250 | + "Lints a .bicep file.", |
| 251 | + "--pattern", |
| 252 | + "--no-restore", |
| 253 | + "--diagnostics-format"); |
| 254 | + } |
| 255 | + } |
| 256 | + |
| 257 | + [TestMethod] |
| 258 | + public async Task JsonRpc_Help_ShouldSucceed_WithExpectedOutput() |
| 259 | + { |
| 260 | + var (output, error, result) = await Bicep("jsonrpc", "--help"); |
| 261 | + |
| 262 | + using (new AssertionScope()) |
| 263 | + { |
| 264 | + result.Should().Be(0); |
| 265 | + error.Should().BeEmpty(); |
| 266 | + output.Should().ContainAll( |
| 267 | + "jsonrpc", |
| 268 | + "JSONRPC", |
| 269 | + "--pipe", |
| 270 | + "--socket", |
| 271 | + "--stdio"); |
| 272 | + } |
| 273 | + } |
| 274 | + |
| 275 | + [TestMethod] |
| 276 | + public async Task LocalDeploy_Help_ShouldSucceed_WithExpectedOutput() |
| 277 | + { |
| 278 | + var (output, error, result) = await Bicep("local-deploy", "--help"); |
| 279 | + |
| 280 | + using (new AssertionScope()) |
| 281 | + { |
| 282 | + result.Should().Be(0); |
| 283 | + error.Should().BeEmpty(); |
| 284 | + output.Should().ContainAll( |
| 285 | + "local-deploy", |
| 286 | + "local deployment", |
| 287 | + "--no-restore", |
| 288 | + "--format"); |
| 289 | + } |
| 290 | + } |
| 291 | + |
| 292 | + [TestMethod] |
| 293 | + public async Task Snapshot_Help_ShouldSucceed_WithExpectedOutput() |
| 294 | + { |
| 295 | + var (output, error, result) = await Bicep("snapshot", "--help"); |
| 296 | + |
| 297 | + using (new AssertionScope()) |
| 298 | + { |
| 299 | + result.Should().Be(0); |
| 300 | + error.Should().BeEmpty(); |
| 301 | + output.Should().ContainAll( |
| 302 | + "snapshot", |
| 303 | + "deployment snapshot", |
| 304 | + "--mode", |
| 305 | + "--tenant-id", |
| 306 | + "--subscription-id", |
| 307 | + "--location", |
| 308 | + "--resource-group", |
| 309 | + "--deployment-name"); |
| 310 | + } |
| 311 | + } |
| 312 | + |
| 313 | + [TestMethod] |
| 314 | + public async Task Deploy_Help_ShouldSucceed_WithExpectedOutput() |
| 315 | + { |
| 316 | + var (output, error, result) = await Bicep("deploy", "--help"); |
| 317 | + |
| 318 | + using (new AssertionScope()) |
| 319 | + { |
| 320 | + result.Should().Be(0); |
| 321 | + error.Should().BeEmpty(); |
| 322 | + output.Should().ContainAll( |
| 323 | + "deploy", |
| 324 | + "Deploys infrastructure", |
| 325 | + "--no-restore", |
| 326 | + "--format"); |
| 327 | + } |
| 328 | + } |
| 329 | + |
| 330 | + [TestMethod] |
| 331 | + public async Task WhatIf_Help_ShouldSucceed_WithExpectedOutput() |
| 332 | + { |
| 333 | + var (output, error, result) = await Bicep("what-if", "--help"); |
| 334 | + |
| 335 | + using (new AssertionScope()) |
| 336 | + { |
| 337 | + result.Should().Be(0); |
| 338 | + error.Should().BeEmpty(); |
| 339 | + output.Should().ContainAll( |
| 340 | + "what-if", |
| 341 | + "Previews the changes", |
| 342 | + "--no-restore"); |
| 343 | + } |
| 344 | + } |
| 345 | + |
| 346 | + [TestMethod] |
| 347 | + public async Task Teardown_Help_ShouldSucceed_WithExpectedOutput() |
| 348 | + { |
| 349 | + var (output, error, result) = await Bicep("teardown", "--help"); |
| 350 | + |
| 351 | + using (new AssertionScope()) |
| 352 | + { |
| 353 | + result.Should().Be(0); |
| 354 | + error.Should().BeEmpty(); |
| 355 | + output.Should().ContainAll( |
| 356 | + "teardown", |
| 357 | + "Tears down resources", |
| 358 | + "--no-restore"); |
| 359 | + } |
| 360 | + } |
| 361 | + |
| 362 | + [TestMethod] |
| 363 | + public async Task Console_Help_ShouldSucceed_WithExpectedOutput() |
| 364 | + { |
| 365 | + var (output, error, result) = await Bicep("console", "--help"); |
| 366 | + |
| 367 | + using (new AssertionScope()) |
| 368 | + { |
| 369 | + result.Should().Be(0); |
| 370 | + error.Should().BeEmpty(); |
| 371 | + output.Should().ContainAll( |
| 372 | + "console", |
| 373 | + "Opens an interactive Bicep console."); |
| 374 | + } |
| 375 | + } |
| 376 | + } |
| 377 | +} |
0 commit comments