summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJeff Brimager <jbrimager@chef.io>2021-07-08 16:46:51 -0500
committerGitHub <noreply@github.com>2021-07-08 14:46:51 -0700
commit503953c517498c627222033b684f6090071dc19a (patch)
tree6e1c6e10607057adfcf016e82fa8981b2fc07131 /spec
parentc55d36d1a7957975ee3b5bb9fe33a6da726fd8c2 (diff)
downloadchef-503953c517498c627222033b684f6090071dc19a.tar.gz
Add habitat resources + content rendering helpers for json/toml/yaml (#11577)
* commiting new resources to clean branch Signed-off-by: Jeff Brimager <jbrimager@chef.io> * reworked toml_dumper resource helper to make sure all end statements were correct and it was being made available to other resource Signed-off-by: Jeff Brimager <jbrimager@chef.io> * changing implementation of toml_deumper to match how the cron_validations helper was implemented Signed-off-by: Jeff Brimager <jbrimager@chef.io> * changing implementation of toml_dumper to match how the cron_validations helper was implemented Signed-off-by: Jeff Brimager <jbrimager@chef.io> * calling toml dumper as a method Signed-off-by: Jeff Brimager <jbrimager@chef.io> * testing new method for toml_dumper helper Signed-off-by: Jeff Brimager <jbrimager@chef.io> * adding "use" statement for toml helper in habitat_config and habitat_toml Signed-off-by: Jeff Brimager <jbrimager@chef.io> * fixing relational mapping with toml_dumper Signed-off-by: Jeff Brimager <jbrimager@chef.io> * using Chef::ResourceHelper::TomlDumper as method to create toml Signed-off-by: Jeff Brimager <jbrimager@chef.io> * correcting syntax error for Chef::ResourceHelpers:: in the habitat_config and habitat_user_toml resource Signed-off-by: Jeff Brimager <jbrimager@chef.io> * adding a render helper Signed-off-by: Jeff Brimager <jbrimager@chef.io> * moved files to correct directories for render_helpers and corrected resource syntax Signed-off-by: Jeff Brimager <jbrimager@chef.io> * chefstyle corrections Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed renderhelers form chef-utils. there by mistake Signed-off-by: Jeff Brimager <jbrimager@chef.io> * corrected class for render helpers Signed-off-by: Jeff Brimager <jbrimager@chef.io> * fixed broken end statement in chef/dsl/toml.rb Signed-off-by: Jeff Brimager <jbrimager@chef.io> * corrected render helper class syntax line 23. was set as a module ; Signed-off-by: Jeff Brimager <jbrimager@chef.io> * corrected dsl helper mapping for render_helpers in spec tests Signed-off-by: Jeff Brimager <jbrimager@chef.io> * wiring chef-utls/internal to render_helpers Signed-off-by: Jeff Brimager <jbrimager@chef.io> * remove "include internal" from render_helpers Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed old helper from habitat_config and habitat_user_toml resources Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed old helper from habitat_config and habitat_user_toml resources Signed-off-by: Jeff <jbrimager@gmail.com> * removed old helper from habitat_config and habitat_user_toml resources Signed-off-by: Jeff Brimager <jbrimager@chef.io> * chefstyle corrections on render_helpers_spec Signed-off-by: Jeff Brimager <jbrimager@chef.io> * chefstyle corrections on chef-utils/lib/chef-utils.rb Signed-off-by: Jeff Brimager <jbrimager@chef.io> * added all documentation to resources Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaned up render_helper_spec.rb Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaning up spellcheck errors Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing unused variable from habitat package provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * correecting bad syntaxt in habitat_package Signed-off-by: Jeff Brimager <jbrimager@chef.io> * temporarioly remove prperty descriptions from habitat_install Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing documentation changes the habitat_package and habitat_sup as well Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaninig up commented issues Signed-off-by: Jeff Brimager <jbrimager@chef.io> * added all property descriptions back to habitat resources Signed-off-by: Jeff Brimager <jbrimager@chef.io> * corrected chefstule errros Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaned up descriptions in habitat_install Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaning up bad trailing spaces Signed-off-by: Jeff Brimager <jbrimager@chef.io> * fixed kitchen runlist for linux Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing habitat from package providers Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaned up bad character in habitat install Signed-off-by: Jeff Brimager <jbrimager@chef.io> * fixed habitat_package resource Signed-off-by: Jeff Brimager <jbrimager@chef.io> * changing how habitat_package connects to its provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * converted habitat_package_provider to a resource class Signed-off-by: Jeff Brimager <jbrimager@chef.io> * chefstyle corrections made Signed-off-by: Jeff Brimager <jbrimager@chef.io> * connecting habitat_package with _provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * testing habitat_package_provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * changing resource method for habit_package_provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * more chefstyle corrections Signed-off-by: Jeff Brimager <jbrimager@chef.io> * reverted changes Signed-off-by: Jeff Brimager <jbrimager@chef.io> * correcting end statements and bad syntax Signed-off-by: Jeff Brimager <jbrimager@chef.io> * trying to alter habitat_package_provider to work as a resource Signed-off-by: Jeff Brimager <jbrimager@chef.io> * altering the methods for remove_package in habitat_provider_package Signed-off-by: Jeff Brimager <jbrimager@chef.io> * mapping exceptions to habitat package provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * habitat_package resource connected to habitat_package_provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed V2 hab version compare from habitat_package provider we will only support systemd moving forward Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing yesterdays changes to see if they are causing the issue with habitat_sup Signed-off-by: Jeff Brimager <jbrimager@chef.io> * reverting the habitat_package provider to previous state Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing bad test Signed-off-by: Jeff Brimager <jbrimager@chef.io> * restored the version_compare in habitat provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * correcting spellcheck issues Signed-off-by: Jeff Brimager <jbrimager@chef.io> * commiting new resources to clean branch Signed-off-by: Jeff Brimager <jbrimager@chef.io> * reworked toml_dumper resource helper to make sure all end statements were correct and it was being made available to other resource Signed-off-by: Jeff Brimager <jbrimager@chef.io> * changing implementation of toml_deumper to match how the cron_validations helper was implemented Signed-off-by: Jeff Brimager <jbrimager@chef.io> * changing implementation of toml_dumper to match how the cron_validations helper was implemented Signed-off-by: Jeff Brimager <jbrimager@chef.io> * calling toml dumper as a method Signed-off-by: Jeff Brimager <jbrimager@chef.io> * testing new method for toml_dumper helper Signed-off-by: Jeff Brimager <jbrimager@chef.io> * adding "use" statement for toml helper in habitat_config and habitat_toml Signed-off-by: Jeff Brimager <jbrimager@chef.io> * fixing relational mapping with toml_dumper Signed-off-by: Jeff Brimager <jbrimager@chef.io> * using Chef::ResourceHelper::TomlDumper as method to create toml Signed-off-by: Jeff Brimager <jbrimager@chef.io> * correcting syntax error for Chef::ResourceHelpers:: in the habitat_config and habitat_user_toml resource Signed-off-by: Jeff Brimager <jbrimager@chef.io> * adding a render helper Signed-off-by: Jeff Brimager <jbrimager@chef.io> * moved files to correct directories for render_helpers and corrected resource syntax Signed-off-by: Jeff Brimager <jbrimager@chef.io> * chefstyle corrections Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed renderhelers form chef-utils. there by mistake Signed-off-by: Jeff Brimager <jbrimager@chef.io> * corrected class for render helpers Signed-off-by: Jeff Brimager <jbrimager@chef.io> * fixed broken end statement in chef/dsl/toml.rb Signed-off-by: Jeff Brimager <jbrimager@chef.io> * corrected render helper class syntax line 23. was set as a module ; Signed-off-by: Jeff Brimager <jbrimager@chef.io> * corrected dsl helper mapping for render_helpers in spec tests Signed-off-by: Jeff Brimager <jbrimager@chef.io> * wiring chef-utls/internal to render_helpers Signed-off-by: Jeff Brimager <jbrimager@chef.io> * remove "include internal" from render_helpers Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed old helper from habitat_config and habitat_user_toml resources Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed old helper from habitat_config and habitat_user_toml resources Signed-off-by: Jeff Brimager <jbrimager@chef.io> * chefstyle corrections on render_helpers_spec Signed-off-by: Jeff Brimager <jbrimager@chef.io> * chefstyle corrections on chef-utils/lib/chef-utils.rb Signed-off-by: Jeff Brimager <jbrimager@chef.io> * added all documentation to resources Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaned up render_helper_spec.rb Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaning up spellcheck errors Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing unused variable from habitat package provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * correecting bad syntaxt in habitat_package Signed-off-by: Jeff Brimager <jbrimager@chef.io> * temporarioly remove prperty descriptions from habitat_install Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing documentation changes the habitat_package and habitat_sup as well Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaninig up commented issues Signed-off-by: Jeff Brimager <jbrimager@chef.io> * added all property descriptions back to habitat resources Signed-off-by: Jeff Brimager <jbrimager@chef.io> * corrected chefstule errros Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaned up descriptions in habitat_install Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaning up bad trailing spaces Signed-off-by: Jeff Brimager <jbrimager@chef.io> * fixed kitchen runlist for linux Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing habitat from package providers Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaned up bad character in habitat install Signed-off-by: Jeff Brimager <jbrimager@chef.io> * fixed habitat_package resource Signed-off-by: Jeff Brimager <jbrimager@chef.io> * changing how habitat_package connects to its provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * converted habitat_package_provider to a resource class Signed-off-by: Jeff Brimager <jbrimager@chef.io> * chefstyle corrections made Signed-off-by: Jeff Brimager <jbrimager@chef.io> * connecting habitat_package with _provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * testing habitat_package_provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * changing resource method for habit_package_provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * more chefstyle corrections Signed-off-by: Jeff Brimager <jbrimager@chef.io> * reverted changes Signed-off-by: Jeff Brimager <jbrimager@chef.io> * correcting end statements and bad syntax Signed-off-by: Jeff Brimager <jbrimager@chef.io> * trying to alter habitat_package_provider to work as a resource Signed-off-by: Jeff Brimager <jbrimager@chef.io> * altering the methods for remove_package in habitat_provider_package Signed-off-by: Jeff Brimager <jbrimager@chef.io> * mapping exceptions to habitat package provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * habitat_package resource connected to habitat_package_provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed V2 hab version compare from habitat_package provider we will only support systemd moving forward Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing yesterdays changes to see if they are causing the issue with habitat_sup Signed-off-by: Jeff Brimager <jbrimager@chef.io> * reverting the habitat_package provider to previous state Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing bad test Signed-off-by: Jeff Brimager <jbrimager@chef.io> * restored the version_compare in habitat provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * correcting spellcheck issues Signed-off-by: Jeff Brimager <jbrimager@chef.io> * adding documentation to habitat resources Signed-off-by: Jeff Brimager <jbrimager@chef.io> * correcting doc format in habitat_sup Signed-off-by: Jeff Brimager <jbrimager@chef.io> * cleaned up descrtipstions and added proper tagging for doc generation Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed require_relative "toml" from render helpers Signed-off-by: Jeff Brimager <jbrimager@chef.io> * misunderstanding in refactor. code added back for require_relative Signed-off-by: Jeff Brimager <jbrimager@chef.io> * misunderstanding in refactor. code added back for require_relative Signed-off-by: Jeff Brimager <jbrimager@chef.io> * added use_multipackage_api to habitat_package_provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * added guard to make sure habitat linux was only tested on systemd capable machines Signed-off-by: Jeff Brimager <jbrimager@chef.io> * extended timeout loops on _habitat_services kitchen tests Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed unnecessary tesys Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed deprecated test method for habitat package version_compare Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removing private tag in the habitat package provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * more corrections to the habitat_package provider for testing Signed-off-by: Jeff Brimager <jbrimager@chef.io> * removed bad line in habitat package provider Signed-off-by: Jeff Brimager <jbrimager@chef.io> * corrected punctuation on all habitat descriptions Signed-off-by: Jeff Brimager <jbrimager@chef.io> * adding notes to tk runs to explain why service loads are looped Signed-off-by: Jeff Brimager <jbrimager@chef.io> * correcting spellcheck errors Signed-off-by: Jeff Brimager <jbrimager@chef.io> * merging master Signed-off-by: Jeff Brimager <jbrimager@chef.io>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/dsl/render_helpers_spec.rb102
-rw-r--r--spec/unit/provider/mount/aix_spec.rb2
2 files changed, 103 insertions, 1 deletions
diff --git a/spec/unit/dsl/render_helpers_spec.rb b/spec/unit/dsl/render_helpers_spec.rb
new file mode 100644
index 0000000000..86bdac9e77
--- /dev/null
+++ b/spec/unit/dsl/render_helpers_spec.rb
@@ -0,0 +1,102 @@
+#
+# Copyright:: Copyright (c) Chef Software Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "spec_helper"
+require "chef/dsl/render_helpers"
+
+describe Chef::DSL::RenderHelpers do
+
+ hash = {
+ "golf": "hotel",
+ "kilo": %w{lima mike},
+ "india": {
+ "juliett": "blue",
+ },
+ "alpha": {
+ "charlie": true,
+ "bravo": 10,
+ },
+ "echo": "foxtrot",
+ }
+
+ context "render_json" do
+ json = Chef::DSL::RenderHelpers.render_json(hash)
+ describe "JSON content" do
+ it "expected JSON output" do
+ expected = <<-EXPECTED
+{
+ "golf": "hotel",
+ "kilo": [
+ "lima",
+ "mike"
+ ],
+ "india": {
+ "juliett": "blue"
+ },
+ "alpha": {
+ "charlie": true,
+ "bravo": 10
+ },
+ "echo": "foxtrot"
+}
+ EXPECTED
+ expect(json).to eq(expected)
+ end
+ end
+ end
+
+ context "render_toml" do
+ toml = Chef::DSL::RenderHelpers.render_toml(hash)
+ describe "TOML content" do
+ it "expected TOML output" do
+ expected = <<-EXPECTED
+echo = "foxtrot"
+golf = "hotel"
+kilo = ["lima", "mike"]
+[alpha]
+bravo = 10
+charlie = true
+[india]
+juliett = "blue"
+ EXPECTED
+ expect(toml).to eq(expected)
+ end
+ end
+ end
+
+ context "render_yaml" do
+ yaml = Chef::DSL::RenderHelpers.render_yaml(hash)
+ describe "YAML content" do
+ it "expected YAML output" do
+ expected = <<-EXPECTED
+---
+golf: hotel
+kilo:
+- lima
+- mike
+india:
+ juliett: blue
+alpha:
+ charlie: true
+ bravo: 10
+echo: foxtrot
+ EXPECTED
+ expect(yaml).to eq(expected)
+ end
+ end
+ end
+end
diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb
index 3d77a23bd6..44556866e8 100644
--- a/spec/unit/provider/mount/aix_spec.rb
+++ b/spec/unit/provider/mount/aix_spec.rb
@@ -202,7 +202,7 @@ describe Chef::Provider::Mount::Aix do
it "should enable mount if it is mounted and not enabled" do
@new_resource.options("nodev,rw")
stub_mounted_enabled(@provider, @mounted_output, "")
- # Add existing mount to test enable action appends additional mount with seperating blank line
+ # Add existing mount to test enable action appends additional mount with separating blank line
filesystems = StringIO.new
filesystems.puts <<~ETCFILESYSTEMS
/tmp/abc: