From 25750e7495e178fc22a07cd1d9dcfd34c7141036 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Mon, 21 Oct 2019 00:18:02 -0500 Subject: hscript: Implement Language, add tests --- tests/fixtures/0115-language-simple.installfile | 6 +++ tests/fixtures/0116-language-country.installfile | 6 +++ tests/fixtures/0117-language-codeset.installfile | 6 +++ .../fixtures/0118-language-c-exception.installfile | 6 +++ tests/fixtures/0119-language-invalid.installfile | 6 +++ tests/fixtures/0120-language-iso.installfile | 6 +++ tests/fixtures/0121-language-duplicate.installfile | 7 ++++ tests/spec/validator_spec.rb | 43 ++++++++++++++++++++++ 8 files changed, 86 insertions(+) create mode 100644 tests/fixtures/0115-language-simple.installfile create mode 100644 tests/fixtures/0116-language-country.installfile create mode 100644 tests/fixtures/0117-language-codeset.installfile create mode 100644 tests/fixtures/0118-language-c-exception.installfile create mode 100644 tests/fixtures/0119-language-invalid.installfile create mode 100644 tests/fixtures/0120-language-iso.installfile create mode 100644 tests/fixtures/0121-language-duplicate.installfile (limited to 'tests') diff --git a/tests/fixtures/0115-language-simple.installfile b/tests/fixtures/0115-language-simple.installfile new file mode 100644 index 0000000..ced3f0c --- /dev/null +++ b/tests/fixtures/0115-language-simple.installfile @@ -0,0 +1,6 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +language cy diff --git a/tests/fixtures/0116-language-country.installfile b/tests/fixtures/0116-language-country.installfile new file mode 100644 index 0000000..a6812a9 --- /dev/null +++ b/tests/fixtures/0116-language-country.installfile @@ -0,0 +1,6 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +language ie_IE diff --git a/tests/fixtures/0117-language-codeset.installfile b/tests/fixtures/0117-language-codeset.installfile new file mode 100644 index 0000000..ae18d4a --- /dev/null +++ b/tests/fixtures/0117-language-codeset.installfile @@ -0,0 +1,6 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +language zh_TW.UTF-8 diff --git a/tests/fixtures/0118-language-c-exception.installfile b/tests/fixtures/0118-language-c-exception.installfile new file mode 100644 index 0000000..4e2f53d --- /dev/null +++ b/tests/fixtures/0118-language-c-exception.installfile @@ -0,0 +1,6 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +language C.UTF-8 diff --git a/tests/fixtures/0119-language-invalid.installfile b/tests/fixtures/0119-language-invalid.installfile new file mode 100644 index 0000000..209eacf --- /dev/null +++ b/tests/fixtures/0119-language-invalid.installfile @@ -0,0 +1,6 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +language klingon diff --git a/tests/fixtures/0120-language-iso.installfile b/tests/fixtures/0120-language-iso.installfile new file mode 100644 index 0000000..63f92e5 --- /dev/null +++ b/tests/fixtures/0120-language-iso.installfile @@ -0,0 +1,6 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +language en_US.ISO-8859-1 diff --git a/tests/fixtures/0121-language-duplicate.installfile b/tests/fixtures/0121-language-duplicate.installfile new file mode 100644 index 0000000..83f7314 --- /dev/null +++ b/tests/fixtures/0121-language-duplicate.installfile @@ -0,0 +1,7 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +language en +language en diff --git a/tests/spec/validator_spec.rb b/tests/spec/validator_spec.rb index 08f5886..3ed43ea 100644 --- a/tests/spec/validator_spec.rb +++ b/tests/spec/validator_spec.rb @@ -186,6 +186,44 @@ RSpec.describe 'HorizonScript validation', :type => :aruba do expect(last_command_started).to have_output(/error: .*firmware.*value/) end end + context "for 'language' key" do + # Runner.Validate.language + # Runner.Validate.language.Format + it "supports a simple language" do + use_fixture '0115-language-simple.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "supports a language_territory value" do + use_fixture '0116-language-country.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "supports the UTF-8 codeset" do + use_fixture '0117-language-codeset.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "supports the special case C.UTF-8" do + use_fixture '0118-language-c-exception.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "requires a valid language" do + use_fixture '0119-language-invalid.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*language.*invalid/) + end + it "requires the UTF-8 codeset" do + use_fixture '0120-language-iso.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*language.*codeset/) + end + end context "for 'mount' key" do # Runner.Validate.mount. it "fails with an invalid value" do @@ -537,6 +575,11 @@ RSpec.describe 'HorizonScript validation', :type => :aruba do skip "This build does not support firmware" if last_command_started.stdout !~ /supports non-free/ expect(last_command_started).to have_output(/error: .*duplicate.*firmware/) end + it "fails with a duplicate 'language' key" do + use_fixture '0121-language-duplicate.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*duplicate.*language/) + end end context "user account keys:" do context "'username'" do -- cgit v1.2.3-70-g09d2