Skip to content

Commit a88fe54

Browse files
committed
(GH-489) Add integration tests for PDK resolver
Previously there we not tests to determine the behaviour of the PDK Resolver. This commit adds some basic integration tests to confirm that the PDK Resolver does indeed find the puppet gem versions inside a real PDK installation.
1 parent cd4059c commit a88fe54

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
sudo: false
33
language: cpp
44

5+
# Must be Trusty!
6+
# For some reason Xenial fails with exit code 1
7+
dist: trusty
8+
59
os:
610
- linux
711
- osx
@@ -24,6 +28,21 @@ before_install: true
2428

2529
install:
2630
- "export BUILD_VERSION=0.7.0-travis.$TRAVIS_BUILD_NUMBER"
31+
# Install PDK for Ubuntu 14.04 (Trusty)
32+
- if [ $TRAVIS_OS_NAME == "linux" ]; then
33+
wget https://apt.puppetlabs.com/puppet6-release-trusty.deb;
34+
sudo dpkg -i puppet6-release-trusty.deb;
35+
sudo apt-get update;
36+
sudo apt-get install pdk;
37+
pdk --version;
38+
fi
39+
# Install PDK for Mac (Disable homebrew auto-update)
40+
# Uses an absolute path due to shell needing to be reloaded.
41+
- if [ $TRAVIS_OS_NAME == "osx" ]; then
42+
export HOMEBREW_NO_AUTO_UPDATE=1;
43+
brew cask install puppetlabs/puppet/pdk;
44+
/opt/puppetlabs/pdk/bin/pdk --version;
45+
fi
2746
- if [ "$nodejs_version" != "" ]; then
2847
git clone --depth 1 https://github.com/creationix/nvm.git ./.nvm;
2948
source ./.nvm/nvm.sh;
@@ -41,6 +60,7 @@ install:
4160
npm install -g vsce --silent;
4261
npm install --silent;
4362
node node_modules/gulp/bin/gulp.js bump --version $BUILD_VERSION;
63+
node node_modules/gulp/bin/gulp.js initial;
4464
fi
4565

4666
script:

appveyor.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ install:
3636
3737
Write-Host "Set the package.json version..."
3838
& node node_modules\gulp\bin\gulp.js bump --specific $ENV:APPVEYOR_BUILD_VERSION
39+
40+
Write-Host "Setting up initial configuration..."
41+
& node node_modules\gulp\bin\gulp.js initial
3942
}
43+
- cmd: choco install pdk
44+
- ps: pdk --version
4045

4146
build_script:
4247
- cmd: npm test --silent

src/test/configuration.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,38 @@ suite("Configuration Tests", () => {
4747
var config = CreateAggregrateConfiguration(settings);
4848
assert.equal(config.ruby.pdkBinDir, pdkBinDir);
4949
});
50+
51+
// Note that these integration tests REQUIRE the PDK to be installed locally
52+
// as the fileystem is queried for path information
53+
test("resolves latest PDK Instance with installtype eq pdk", () => {
54+
const settings: ISettings = DefaultWorkspaceSettings();
55+
settings.installType = PuppetInstallType.PDK;
56+
var config = CreateAggregrateConfiguration(settings);
57+
assert.notEqual(config.ruby.pdkGemDir, undefined);
58+
});
59+
60+
test("resolves All Puppet Versions with installtype eq pdk", () => {
61+
const settings: ISettings = DefaultWorkspaceSettings();
62+
settings.installType = PuppetInstallType.PDK;
63+
var config = CreateAggregrateConfiguration(settings);
64+
assert.notEqual(config.ruby.pdkPuppetVersions, undefined);
65+
assert.ok(config.ruby.pdkPuppetVersions.length > 0, "config.ruby.pdkPuppetVersions.length should have at least one element");
66+
});
67+
68+
test("resolves a puppet version with installtype eq pdk", () => {
69+
// Find all of the available puppet settings
70+
let settings: ISettings = DefaultWorkspaceSettings();
71+
settings.installType = PuppetInstallType.PDK;
72+
let config = CreateAggregrateConfiguration(settings);
73+
// Use the first version available
74+
const puppetVersion = config.ruby.pdkPuppetVersions[0];
75+
settings.editorService.puppet = {
76+
version: puppetVersion
77+
};
78+
// Generate the settings again
79+
config = CreateAggregrateConfiguration(settings);
80+
// Assert that pdk specifc information is still available
81+
// TODO: Should we test that version we ask is the version we get?
82+
assert.notEqual(config.ruby.pdkGemDir, undefined);
83+
});
5084
});

0 commit comments

Comments
 (0)