Closed jeffbyrnes closed 8 years ago
Tests you may find useful:
1) spec/spec_helper.rb I added a default platform and version. Any valid values will work, they're just needed to avoid warnings when running tests in spec/package_version_spec.rb.
RSpec.configure do |config|
config.platform = 'ubuntu'
config.version = '16.04'
...
2) spec/package_version_spec.rb (new file)
require 'spec_helper'
require_relative "../libraries/helpers"
describe 'mysql_test::package_version' do
let(:chef_run) do
ChefSpec::ServerRunner.new() do |node|
# Stubs avoid dependency on platform & version for this test
allow(MysqlCookbook::HelpersBase).to receive(:default_client_package_name).and_return 'the_default_client_package_name'
allow(MysqlCookbook::HelpersBase).to receive(:default_server_package_name).and_return 'the_default_server_package_name'
end.converge(described_recipe)
end
describe "the package_version property" do
context 'when it is not set' do
it 'no default value is passed to the install package' do
expect(chef_run).to install_mysql_client_installation_package('default').with(
package_version: nil
)
end
it 'no default value is passed to the mysql_server_installation_package' do
expect(chef_run).to install_mysql_server_installation_package('default').with(
package_version: nil
)
end
end
context 'when it is set' do
it 'is passed to the mysql_client_installation_package' do
expect(chef_run).to install_mysql_client_installation_package('with a specified package version').with(
package_version: 'the-specified-package_version'
)
end
it 'is passed to the mysql_server_installation_package' do
expect(chef_run).to install_mysql_server_installation_package('with a specified package version').with(
package_version: 'the-specified-package_version'
)
end
end
end
end
3) test/cookbooks/mysql_test/recipes/package_version.rb (new file)
mysql_client_installation_package 'default' do
action :create
end
mysql_client_installation_package 'with a specified package version' do
package_version 'the-specified-package_version'
action :create
end
mysql_server_installation_package 'default' do
action :install
end
mysql_server_installation_package 'with a specified package version' do
package_version 'the-specified-package_version'
action :install
end
Results:
prompt$ rspec spec/package_version_spec.rb
mysql_test::package_version
the package_version property
when it is not set
no default value is passed to the install package
no default value is passed to the mysql_server_installation_package
when it is set
is passed to the mysql_client_installation_package
is passed to the mysql_server_installation_package
...
Thank you so much for putting this together. We really needed to back this out so we could get some stability here.
@tas50 thanks for getting this out so quickly!
A million thanks from here too :+1:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Description
This removes the hardcoded package versions, and the default behavior of using these hardcoded versions, in favor of a less fragile method of using the
major_version
to install MySQL.An operator may still specify a
package_version
if they wish.Issues Resolved
Check List