document mysql_server_id fact and add spec tests

add spec tests, expand documentation to mention lo behaviour
also, rename fact, for, consistency.
This commit is contained in:
Igor Galić 2015-03-02 14:28:34 +01:00
parent dbf54cefe8
commit d7077b43d2
3 changed files with 35 additions and 0 deletions

View file

@ -768,6 +768,14 @@ The name of the MySQL plugin to manage.
The library file name.
###Facts
####`mysql_server_id`
Generates a unique id, based on the node's MAC address, which can be used as
`server_id`. This fact will *always* return `0` on all nodes which only have
loopback interfaces. Given those nodes' connnectivity that's probably okay.
##Limitations
This module has been tested on:

View file

@ -0,0 +1,27 @@
require "spec_helper"
describe Facter::Util::Fact do
before {
Facter.clear
}
describe "mysql_server_id" do
context "igalic's laptop" do
before :each do
Facter.fact(:macadddress).stubs(:value).returns('3c:97:0e:69:fb:e1')
end
it do
Facter.fact(:mysql_server_id).value.to_s.should == '72898961'
end
end
context "node with lo only" do
before :each do
Facter.fact(:macadddress).stubs(:value).returns('00:00:00:00:00:00')
end
it do
Facter.fact(:mysql_server_id).value.should == '0'
end
end
end
end