|
21 | 21 | expect(val1).to eq(val2) |
22 | 22 | end |
23 | 23 |
|
| 24 | + it "allows extra arguments to control the random rotation on a single host" do |
| 25 | + val1 = fqdn_rotate("abcdefg", :extra_identifier => [1, "different", "host"]) |
| 26 | + val2 = fqdn_rotate("abcdefg", :extra_identifier => [2, "different", "host"]) |
| 27 | + expect(val1).not_to eq(val2) |
| 28 | + end |
| 29 | + |
| 30 | + it "considers the same host and same extra arguments to have the same random rotation" do |
| 31 | + val1 = fqdn_rotate("abcdefg", :extra_identifier => [1, "same", "host"]) |
| 32 | + val2 = fqdn_rotate("abcdefg", :extra_identifier => [1, "same", "host"]) |
| 33 | + expect(val1).to eq(val2) |
| 34 | + end |
| 35 | + |
24 | 36 | it "should rotate a string to give different values on different hosts" do |
25 | 37 | val1 = fqdn_rotate("abcdefg", :host => 'one') |
26 | 38 | val2 = fqdn_rotate("abcdefg", :host => 'two') |
|
51 | 63 |
|
52 | 64 | def fqdn_rotate(value, args = {}) |
53 | 65 | host = args[:host] || '127.0.0.1' |
| 66 | + extra = args[:extra_identifier] || [] |
54 | 67 |
|
55 | 68 | # workaround not being able to use let(:facts) because some tests need |
56 | 69 | # multiple different hostnames in one context |
57 | 70 | scope.stubs(:lookupvar).with("::fqdn").returns(host) |
58 | 71 |
|
59 | | - scope.function_fqdn_rotate([value]) |
| 72 | + function_args = [value] + extra |
| 73 | + scope.function_fqdn_rotate(function_args) |
60 | 74 | end |
61 | 75 | end |
0 commit comments