Skip to content

Commit af8a6d7

Browse files
committed
Use the new fact for version discovery.
1 parent d179857 commit af8a6d7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/puppet/provider/mysql.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def mysqld_type
3333
def self.mysqld_version_string
3434
# we cache the result ...
3535
return @mysqld_version_string unless @mysqld_version_string.nil?
36-
@mysqld_version_string = mysqld(['-V'].compact)
36+
@mysqld_version_string = Facter.value(:mysqld_version)
3737
return @mysqld_version_string
3838
end
3939

spec/unit/puppet/provider/mysql_user/mysql_spec.rb

+8-3
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,15 @@
200200
end
201201

202202
describe 'self.mysqld_version' do
203-
it 'queries mysql if unset' do
203+
it 'uses the mysqld_version fact if unset' do
204204
provider.class.instance_variable_set(:@mysqld_version_string, nil)
205-
provider.class.expects(:mysqld).with(['-V'])
206-
expect(provider.mysqld_version).to be_nil
205+
Facter.stubs(:value).with(:mysqld_version).returns('5.6.24')
206+
expect(provider.mysqld_version).to eq '5.6.24'
207+
end
208+
it 'returns nil if the mysqld_version fact is absent' do
209+
provider.class.instance_variable_set(:@mysqld_version_string, nil)
210+
Facter.stubs(:value).with(:mysqld_version).returns(nil)
211+
expect(provider.mysqld_version).to eq nil
207212
end
208213
it 'returns 5.7.6 for "mysqld Ver 5.7.6 for Linux on x86_64 (MySQL Community Server (GPL))"' do
209214
provider.class.instance_variable_set(:@mysqld_version_string, 'mysqld Ver 5.7.6 for Linux on x86_64 (MySQL Community Server (GPL))')

0 commit comments

Comments
 (0)