Skip to content

Commit 5cf52f4

Browse files
author
Jason Heath
committed
Adds e2e test for hab plan cli command
Signed-off-by: Jason Heath <jason.heath@progress.com>
1 parent cb891ff commit 5cf52f4

1 file changed

Lines changed: 103 additions & 0 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
Describe 'hab plan render' {
2+
3+
BeforeAll {
4+
$tempdir = New-TemporaryDirectory
5+
6+
$output = hab plan render ./test/fixtures/render/consul/config/consul_config.json `
7+
--default-toml ./test/fixtures/render/consul/default.toml `
8+
--mock-data ./test/fixtures/render/consul/override.json `
9+
--render-dir $tempdir `
10+
--user-toml ./test/fixtures/render/consul/user.toml `
11+
--print 2>&1
12+
13+
$outfile = Join-Path -Path $tempdir consul_config.json
14+
}
15+
16+
AfterAll { Remove-Item -Path $tempdir -Recurse -Force }
17+
18+
It '--print should work' {
19+
$output | Should -Not -BeNullOrEmpty
20+
}
21+
22+
It '--render-dir should work' {
23+
$outfile | Should -Exist
24+
}
25+
26+
It '--default-toml should work' {
27+
$outfile | Should -FileContentMatch 'IN_DEFAULT_TOML'
28+
}
29+
30+
It '--mock-data should work' {
31+
$outfile | Should -FileContentMatch 'IN_OVERRIDE_JSON'
32+
}
33+
34+
It '--user-toml should work' {
35+
$outfile | Should -FileContentMatch 'IN_USER_TOML'
36+
}
37+
}
38+
39+
Describe 'hab plan init' {
40+
41+
BeforeAll {
42+
$testroot = Get-Location
43+
if ($IsWindows) {
44+
$plan_file = 'plan.ps1'
45+
} else {
46+
$plan_file = 'plan.sh'
47+
}
48+
# This always be just hab for committed code but if you are working
49+
# locally to extend or debug these tests then you can swap the
50+
# variables to use your locally built hab binary
51+
# $hab = Join-Path -Path $testroot target debug hab
52+
$hab = 'hab'
53+
}
54+
55+
BeforeEach {
56+
$tempdir = New-TemporaryDirectory
57+
Set-Location $tempdir
58+
$plan_path = Join-Path -Path $tempdir bar $plan_file
59+
}
60+
61+
AfterEach {
62+
Set-Location $testroot
63+
Remove-Item -Path $tempdir -Recurse -Force
64+
}
65+
66+
# NOTE about the tests that follow. When testing the scaffolding there was
67+
# some weirdness with string interpolation where $ needed to be escaped even
68+
# inside of a single quoted string and $ is Windows specific which we want
69+
# to smooth over anyway. So the scaffolding asserts intentionally drop '#'
70+
# and '$' to just stay away from any weirdness at all. In addition, there
71+
# was an issue in which the code was defaulting to "core/scaffolding-ruby"
72+
# even when the --scaffolding option wasn't specified so the explicit
73+
# denial of "core/scaffolding-ruby" is about making sure that defaulting
74+
# is not occuring somehow and testing "core/scaffolding-go" is about making
75+
# sure the explicit choice was exercised.
76+
77+
it 'normal plan file (scaffolding placeholder)' {
78+
Invoke-NativeCommand "$hab" plan init --origin foo bar 2>&1 | Out-Null
79+
$plan_path | Should -Exist
80+
$plan_path | Should -FileContentMatch "# This file is the heart of your application's habitat."
81+
$plan_path | Should -FileContentMatch 'pkg_scaffolding="some/scaffolding"'
82+
$plan_path | Should -Not -FileContentMatch 'pkg_scaffolding="core/scaffolding-ruby"'
83+
$plan_path | Should -Not -FileContentMatch 'pkg_scaffolding="core/scaffolding-go"'
84+
}
85+
86+
it 'minimal plan file (scaffolding placeholder)' {
87+
Invoke-NativeCommand "$hab" plan init --origin foo --min bar 2>&1 | Out-Null
88+
$plan_path | Should -Exist
89+
$plan_path | Should -Not -FileContentMatch "# This file is the heart of your application's habitat."
90+
$plan_path | Should -FileContentMatch 'pkg_scaffolding="some/scaffolding"'
91+
$plan_path | Should -Not -FileContentMatch 'pkg_scaffolding="core/scaffolding-ruby"'
92+
$plan_path | Should -Not -FileContentMatch 'pkg_scaffolding="core/scaffolding-go"'
93+
}
94+
95+
it 'minimal plan file with scaffolding specified' {
96+
Invoke-NativeCommand "$hab" plan init --origin foo --min --scaffolding go bar 2>&1 | Out-Null
97+
$plan_path | Should -Exist
98+
$plan_path | Should -Not -FileContentMatch "# This file is the heart of your application's habitat."
99+
$plan_path | Should -Not -FileContentMatch 'pkg_scaffolding="some/scaffolding"'
100+
$plan_path | Should -Not -FileContentMatch 'pkg_scaffolding="core/scaffolding-ruby"'
101+
$plan_path | Should -FileContentMatch 'pkg_scaffolding="core/scaffolding-go"'
102+
}
103+
}

0 commit comments

Comments
 (0)