Repository navigation
Expand file tree
/
Copy pathdab-smoke-test-script.ps1
More file actions
71 lines (60 loc) · 2.48 KB
/
Copy pathdab-smoke-test-script.ps1
File metadata and controls
71 lines (60 loc) · 2.48 KB
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
62
63
64
65
66
67
68
69
70
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# This file validates the executables are passing the following basic checks:
# 1. Correct version of DAB is generated
# 2. HelpWindow gets displayed on the Console
# 3. Config file gets generated successfully.
param (
[Parameter (Mandatory=$true)][string] $BuildConfiguration,
[Parameter (Mandatory=$true)][string] $BuildOutputDir,
[Parameter (Mandatory=$true)][string] $OsName,
[Parameter (Mandatory=$true)][string] $DabVersion
)
# Getting executable file path for DAB
switch ($OsName) {
"Windows_NT"{
$RID = "win-x64"
}
"Linux"{
$RID = "linux-x64"
}
"Darwin"{
$RID = "osx-x64"
}
}
$executableFileDirectory = "$BuildOutputDir/publish/$BuildConfiguration/$RID/dab"
$executableDAB = "$executableFileDirectory/Microsoft.DataApiBuilder"
$configFileName = "dab-config-smoke-test.json"
describe SmokeTest {
it 'Check Version' {
$ver = Invoke-expression "$executableDAB --version"
Write-Host("installed-version: {$ver}")
Write-Host("expected-version: {$DabVersion}")
$ver.Contains("Microsoft.DataApiBuilder $DabVersion") | Should -Be True
}
it 'Check Command Help Window' {
$helpText = Invoke-expression "$executableDAB --help"
# Converting object[] to string
$helpWritterOutput = ""
foreach ($helpText in $helpText)
{
$helpWritterOutput += $helpText
}
# Verifying all the supported commands are displayed on the help window
$helpWritterOutput.Contains("init") | Should -Be True
$helpWritterOutput.Contains("add") | Should -Be True
$helpWritterOutput.Contains("update") | Should -Be True
$helpWritterOutput.Contains("start") | Should -Be True
}
it 'Check Config File is generated' {
Invoke-expression "$executableDAB init -c $configFileName --database-type mssql --connection-string xxxx"
Test-Path -Path $configFileName | Should -Be True
}
it 'Check Generated Config contains the correct path of dab schema' {
$expectedSchemaPath = "https://github.com/Azure/data-api-builder/releases/download/v$DabVersion/dab.draft.schema.json";
$parsedSchema = Get-Content -Raw -Path $configFileName | ConvertFrom-Json
$genratedSchemaPath = $parsedSchema.'$schema'
Write-Host("genrated-schema-path: {$genratedSchemaPath}")
$genratedSchemaPath.Equals($expectedSchemaPath) | Should -Be True
}
}