Sfoglia il codice sorgente

Adding test + spec

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO 3 anni fa
parent
commit
488e88a68d

+ 3 - 0
cookbooks/workstation/recipes/default.rb

@@ -3,3 +3,6 @@
 # Recipe:: default
 #
 # Copyright:: 2022, The Authors, All Rights Reserved.
+
+include_recipe 'workstation::_etckeeper'
+include_recipe 'workstation::_podman'

+ 2 - 0
cookbooks/workstation/spec/spec_helper.rb

@@ -0,0 +1,2 @@
+require 'chefspec'
+require 'chefspec/berkshelf'

+ 29 - 0
cookbooks/workstation/spec/unit/recipes/_podman.rb_spec.rb

@@ -0,0 +1,29 @@
+#
+# Cookbook:: workstation
+# Spec:: _podman.rb
+#
+# Copyright:: 2022, The Authors, All Rights Reserved.
+
+require 'spec_helper'
+
+describe 'workstation::_podman.rb' do
+  context 'When all attributes are default, on Ubuntu 20.04' do
+    # for a complete list of available platforms and versions see:
+    # https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md
+    platform 'ubuntu', '20.04'
+
+    it 'converges successfully' do
+      expect { chef_run }.to_not raise_error
+    end
+  end
+
+  context 'When all attributes are default, on CentOS 8' do
+    # for a complete list of available platforms and versions see:
+    # https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md
+    platform 'centos', '8'
+
+    it 'converges successfully' do
+      expect { chef_run }.to_not raise_error
+    end
+  end
+end

+ 29 - 0
cookbooks/workstation/spec/unit/recipes/_podman_spec.rb

@@ -0,0 +1,29 @@
+#
+# Cookbook:: workstation
+# Spec:: _podman
+#
+# Copyright:: 2022, The Authors, All Rights Reserved.
+
+require 'spec_helper'
+
+describe 'workstation::_podman' do
+  context 'When all attributes are default, on Ubuntu 20.04' do
+    # for a complete list of available platforms and versions see:
+    # https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md
+    platform 'ubuntu', '20.04'
+
+    it 'converges successfully' do
+      expect { chef_run }.to_not raise_error
+    end
+  end
+
+  context 'When all attributes are default, on CentOS 8' do
+    # for a complete list of available platforms and versions see:
+    # https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md
+    platform 'centos', '8'
+
+    it 'converges successfully' do
+      expect { chef_run }.to_not raise_error
+    end
+  end
+end

+ 29 - 0
cookbooks/workstation/spec/unit/recipes/_tmux_spec.rb

@@ -0,0 +1,29 @@
+#
+# Cookbook:: .
+# Spec:: _tmux
+#
+# Copyright:: 2022, The Authors, All Rights Reserved.
+
+require 'spec_helper'
+
+describe '.::_tmux' do
+  context 'When all attributes are default, on Ubuntu 20.04' do
+    # for a complete list of available platforms and versions see:
+    # https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md
+    platform 'ubuntu', '20.04'
+
+    it 'converges successfully' do
+      expect { chef_run }.to_not raise_error
+    end
+  end
+
+  context 'When all attributes are default, on CentOS 8' do
+    # for a complete list of available platforms and versions see:
+    # https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md
+    platform 'centos', '8'
+
+    it 'converges successfully' do
+      expect { chef_run }.to_not raise_error
+    end
+  end
+end

+ 16 - 0
cookbooks/workstation/test/integration/default/_podman.rb_test.rb

@@ -0,0 +1,16 @@
+# Chef InSpec test for recipe workstation::_podman.rb
+
+# The Chef InSpec reference, with examples and extensive documentation, can be
+# found at https://docs.chef.io/inspec/resources/
+
+unless os.windows?
+  # This is an example test, replace with your own test.
+  describe user('root'), :skip do
+    it { should exist }
+  end
+end
+
+# This is an example test, replace it with your own test.
+describe port(80), :skip do
+  it { should_not be_listening }
+end

+ 16 - 0
cookbooks/workstation/test/integration/default/_podman_test.rb

@@ -0,0 +1,16 @@
+# Chef InSpec test for recipe workstation::_podman
+
+# The Chef InSpec reference, with examples and extensive documentation, can be
+# found at https://docs.chef.io/inspec/resources/
+
+unless os.windows?
+  # This is an example test, replace with your own test.
+  describe user('root'), :skip do
+    it { should exist }
+  end
+end
+
+# This is an example test, replace it with your own test.
+describe port(80), :skip do
+  it { should_not be_listening }
+end

+ 16 - 0
cookbooks/workstation/test/integration/default/_tmux_test.rb

@@ -0,0 +1,16 @@
+# Chef InSpec test for recipe .::_tmux
+
+# The Chef InSpec reference, with examples and extensive documentation, can be
+# found at https://docs.chef.io/inspec/resources/
+
+unless os.windows?
+  # This is an example test, replace with your own test.
+  describe user('root'), :skip do
+    it { should exist }
+  end
+end
+
+# This is an example test, replace it with your own test.
+describe port(80), :skip do
+  it { should_not be_listening }
+end