From 1322a7380e34a8f7b66943ffd10dff3b68dfa806 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 20 Feb 2020 19:13:15 +0000 Subject: [PATCH] Add test for supybot cookbook --- .kitchen.yml | 3 +++ .travis.yml | 3 +++ cookbooks/supybot/attributes/default.rb | 1 + cookbooks/supybot/metadata.rb | 1 + cookbooks/supybot/recipes/default.rb | 2 ++ roles/supybot.rb | 8 -------- test/data_bags/accounts/supybot.json | 5 +++++ test/data_bags/supybot/passwords.json | 4 ++++ test/data_bags/supybot/users.json | 4 ++++ test/integration/supybot/serverspec/supybot_spec.rb | 13 +++++++++++++ 10 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 cookbooks/supybot/attributes/default.rb create mode 100644 test/data_bags/accounts/supybot.json create mode 100644 test/data_bags/supybot/passwords.json create mode 100644 test/data_bags/supybot/users.json create mode 100644 test/integration/supybot/serverspec/supybot_spec.rb diff --git a/.kitchen.yml b/.kitchen.yml index 2e937d121..e91b64040 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -212,6 +212,9 @@ suites: - name: subversion run_list: - recipe[subversion::default] + - name: supybot + run_list: + - recipe[supybot::default] - name: switch2osm run_list: - recipe[switch2osm::default] diff --git a/.travis.yml b/.travis.yml index b9f212d85..d699655dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -160,6 +160,9 @@ jobs: - name: "Test Kitchen (subversion)" script: - bundle exec kitchen test subversion-ubuntu-1804 + - name: "Test Kitchen (supybot)" + script: + - bundle exec kitchen test supybot-ubuntu-1804 - name: "Test Kitchen (switch2osm)" script: - bundle exec kitchen test switch2osm-ubuntu-1804 diff --git a/cookbooks/supybot/attributes/default.rb b/cookbooks/supybot/attributes/default.rb new file mode 100644 index 000000000..1e8be7808 --- /dev/null +++ b/cookbooks/supybot/attributes/default.rb @@ -0,0 +1 @@ +default[:accounts][:users][:supybot][:status] = :role diff --git a/cookbooks/supybot/metadata.rb b/cookbooks/supybot/metadata.rb index 1b372ae22..76dbe20f2 100644 --- a/cookbooks/supybot/metadata.rb +++ b/cookbooks/supybot/metadata.rb @@ -6,4 +6,5 @@ description "Installs and configures supybot" version "1.0.0" supports "ubuntu" +depends "accounts" depends "systemd" diff --git a/cookbooks/supybot/recipes/default.rb b/cookbooks/supybot/recipes/default.rb index d1c1ea32d..7cd8836d7 100644 --- a/cookbooks/supybot/recipes/default.rb +++ b/cookbooks/supybot/recipes/default.rb @@ -17,6 +17,8 @@ # limitations under the License. # +include_recipe "accounts" + users = data_bag_item("supybot", "users") passwords = data_bag_item("supybot", "passwords") diff --git a/roles/supybot.rb b/roles/supybot.rb index 877fc766a..23a64d835 100644 --- a/roles/supybot.rb +++ b/roles/supybot.rb @@ -1,14 +1,6 @@ name "supybot" description "Role applied to all supybot servers" -default_attributes( - :accounts => { - :users => { - :supybot => { :status => :role } - } - } -) - run_list( "recipe[supybot]" ) diff --git a/test/data_bags/accounts/supybot.json b/test/data_bags/accounts/supybot.json new file mode 100644 index 000000000..b623c99a4 --- /dev/null +++ b/test/data_bags/accounts/supybot.json @@ -0,0 +1,5 @@ +{ + "id": "supybot", + "uid": "517", + "comment": "Supybot" +} diff --git a/test/data_bags/supybot/passwords.json b/test/data_bags/supybot/passwords.json new file mode 100644 index 000000000..4ae280fef --- /dev/null +++ b/test/data_bags/supybot/passwords.json @@ -0,0 +1,4 @@ +{ + "id": "passwords", + "nickserv": "nickserv" +} diff --git a/test/data_bags/supybot/users.json b/test/data_bags/supybot/users.json new file mode 100644 index 000000000..7a318dc6e --- /dev/null +++ b/test/data_bags/supybot/users.json @@ -0,0 +1,4 @@ +{ + "id": "users", + "Firefishy": "Firefishy" +} diff --git a/test/integration/supybot/serverspec/supybot_spec.rb b/test/integration/supybot/serverspec/supybot_spec.rb new file mode 100644 index 000000000..97a7db2dc --- /dev/null +++ b/test/integration/supybot/serverspec/supybot_spec.rb @@ -0,0 +1,13 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("supybot") do + it { should be_installed } +end + +describe service("supybot") do + it { should be_enabled } + it { should be_running } +end -- 2.39.5