File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ Facter . add ( :mongodb_version ) do
2+ setcode do
3+ if Facter ::Core ::Execution . which ( 'mongo' )
4+ mongodb_version = Facter ::Core ::Execution . execute ( 'mongo --version 2>&1' )
5+ %r{^MongoDB shell version: ([\w \. ]+)} . match ( mongodb_version ) [ 1 ]
6+ end
7+ end
8+ end
Original file line number Diff line number Diff line change 1+ require "spec_helper"
2+
3+ describe Facter ::Util ::Fact do
4+ before {
5+ Facter . clear
6+ }
7+
8+ describe "mongodb_version" do
9+ context 'with value' do
10+ before :each do
11+ Facter ::Core ::Execution . stubs ( :which ) . with ( 'mongo' ) . returns ( true )
12+ Facter ::Core ::Execution . stubs ( :execute ) . with ( 'mongo --version 2>&1' ) . returns ( 'MongoDB shell version: 3.2.1' )
13+ end
14+ it {
15+ expect ( Facter . fact ( :mongodb_version ) . value ) . to eq ( '3.2.1' )
16+ }
17+ end
18+ end
19+ end
You can’t perform that action at this time.
0 commit comments