diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2023-10-10 23:30:18 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2023-10-10 23:30:18 -0500 |
commit | 615278f3365087e436ee5ea13e0d15bd60718038 (patch) | |
tree | 9b67e19184a743c0ee3672b6266b281a6d7e8799 /tests/spec | |
parent | 8bb3f48cb970a410d93940c675c4a086af9fbcdd (diff) | |
download | horizon-615278f3365087e436ee5ea13e0d15bd60718038.tar.gz horizon-615278f3365087e436ee5ea13e0d15bd60718038.tar.bz2 horizon-615278f3365087e436ee5ea13e0d15bd60718038.tar.xz horizon-615278f3365087e436ee5ea13e0d15bd60718038.zip |
hscript: Allow multiple inheritance
This allows a HorizonScript to inherit from multiple files. Files are parsed
in a system-defined, unspecified order, but all scripts of a given depth are
guaranteed to be parsed before the next depth.
Diffstat (limited to 'tests/spec')
-rw-r--r-- | tests/spec/simulator_spec.rb | 7 | ||||
-rw-r--r-- | tests/spec/validator_spec.rb | 29 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/spec/simulator_spec.rb b/tests/spec/simulator_spec.rb index 6c2d095..8ccf98e 100644 --- a/tests/spec/simulator_spec.rb +++ b/tests/spec/simulator_spec.rb @@ -448,4 +448,11 @@ mtu 9001 expect(last_command_started.stdout).to include("cp /usr/share/user-manager/avatars/circles/Cat.png /target/var/lib/AccountsService/icons/awilfox") end end + context "simulating inheritance" do + it "overrides keys correctly when multiple values are specified" do + use_fixture '0238-inherit-override.installfile' + run_simulate + expect(last_command_started.stdout).to include("hostname overridden.hostname.local") + end + end end diff --git a/tests/spec/validator_spec.rb b/tests/spec/validator_spec.rb index 282d7ca..3a491a0 100644 --- a/tests/spec/validator_spec.rb +++ b/tests/spec/validator_spec.rb @@ -80,6 +80,35 @@ RSpec.describe 'HorizonScript validation', :type => :aruba do run_validate expect(last_command_started).to have_output(/error: .*length/) end + context "inheritance" do + it "supports basic single inheritance" do + use_fixture '0232-inherit-basic.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "requires inherited files to exist" do + use_fixture '0233-inherit-missing.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*non-existent/) + end + it "doesn't get stuck in a loop" do + use_fixture '0264-inherit-test-loop.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*already inherited/) + end + it "supports relative paths" do + use_fixture '0236-inherit-relative.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "still knows incomplete files are incomplete" do + use_fixture '0237-inherit-incomplete.installfile' + run_validate + expect(last_command_started).to have_output(/error: expected/) + end + end context "required keys" do # Runner.Validate.Required. # Runner.Validate.network. |