File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 22
33Facter . add ( 'mysqld_version' ) do
44 setcode do
5- if Facter ::Core ::Execution . which ( 'mysqld' ) || Facter ::Core ::Execution . which ( '/usr/libexec/mysqld' )
6- Facter ::Core ::Execution . execute ( 'env PATH=$PATH:/usr/libexec mysqld --no-defaults -V 2>/dev/null' )
5+ if Facter ::Core ::Execution . which ( 'mysqld' )
6+ Facter ::Core ::Execution . execute ( 'mysqld --no-defaults -V 2>/dev/null' )
7+ elsif Facter ::Core ::Execution . which ( '/usr/libexec/mysqld' )
8+ Facter ::Core ::Execution . execute ( '/usr/libexec/mysqld --no-defaults -V 2>/dev/null' )
79 elsif Facter ::Core ::Execution . which ( 'mariadbd' )
810 Facter ::Core ::Execution . execute ( 'mariadbd --no-defaults -V 2>/dev/null' )
911 end
Original file line number Diff line number Diff line change 1111 context 'with mysqld' do
1212 before :each do
1313 allow ( Facter ::Core ::Execution ) . to receive ( :which ) . with ( 'mysqld' ) . and_return ( '/usr/sbin/mysqld' )
14+ allow ( Facter ::Core ::Execution ) . to receive ( :which ) . with ( '/usr/libexec/mysqld' ) . and_return ( false )
15+ allow ( Facter ::Core ::Execution ) . to receive ( :which ) . with ( 'mariadbd' ) . and_return ( false )
16+ allow ( Facter ::Core ::Execution ) . to receive ( :execute ) . with ( 'mysqld --no-defaults -V 2>/dev/null' )
17+ . and_return ( 'mysqld Ver 5.5.49-37.9 for Linux on x86_64 (Percona Server (GPL), Release 37.9, Revision efa0073)' )
18+ end
19+
20+ it {
21+ expect ( Facter . fact ( :mysqld_version ) . value ) . to eq ( 'mysqld Ver 5.5.49-37.9 for Linux on x86_64 (Percona Server (GPL), Release 37.9, Revision efa0073)' )
22+ }
23+ end
24+
25+ context 'with mysqld in /usr/libexec/mysqld' do
26+ before :each do
27+ allow ( Facter ::Core ::Execution ) . to receive ( :which ) . with ( 'mysqld' ) . and_return ( false )
28+ allow ( Facter ::Core ::Execution ) . to receive ( :which ) . with ( '/usr/libexec/mysqld' ) . and_return ( '/usr/libexec/mysqld' )
1429 allow ( Facter ::Core ::Execution ) . to receive ( :which ) . with ( 'mariadbd' ) . and_return ( false )
15- allow ( Facter ::Core ::Execution ) . to receive ( :execute ) . with ( 'env PATH=$PATH: /usr/libexec mysqld --no-defaults -V 2>/dev/null' )
30+ allow ( Facter ::Core ::Execution ) . to receive ( :execute ) . with ( '/usr/libexec/ mysqld --no-defaults -V 2>/dev/null' )
1631 . and_return ( 'mysqld Ver 5.5.49-37.9 for Linux on x86_64 (Percona Server (GPL), Release 37.9, Revision efa0073)' )
1732 end
1833
You can’t perform that action at this time.
0 commit comments