Skip to content

Commit

Permalink
Fix the new SerfWatcher and add a spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Azhagu Selvan committed Jun 21, 2017
1 parent 5c60428 commit 151ad1c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/synapse/service_watcher/serf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'thread'

module Synapse::ServiceWatcher
class Synapse::ServiceWatcher
class SerfWatcher < BaseWatcher

def initialize(opts = {}, synapse)
Expand All @@ -13,7 +13,6 @@ def initialize(opts = {}, synapse)
@all_backups_except_one = opts['haproxy']['all_backups_except_one']
end
end

def start
@serf_members = '/dev/shm/serf_members.json'
@cycle_delay = 1
Expand Down
30 changes: 30 additions & 0 deletions spec/lib/synapse/serf_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'spec_helper'
require 'synapse/service_watcher/serf'

describe Synapse::ServiceWatcher::SerfWatcher do
let(:mock_synapse) do
mock_synapse = instance_double(Synapse::Synapse)
mockgenerator = Synapse::ConfigGenerator::BaseGenerator.new()
allow(mock_synapse).to receive(:available_generators).and_return({
'haproxy' => mockgenerator
})
mock_synapse
end
let(:discovery) { { 'method' => 'serf', 'hosts' => 'somehost','path' => 'some/path' } }

let(:config) do
{
'name' => 'test',
'haproxy' => {},
'discovery'=> discovery
}
end

context 'SerfWatcher' do
subject { Synapse::ServiceWatcher::SerfWatcher.new(config, mock_synapse) }
it 'should validate' do
expect(subject.send(:validate_discovery_opts)).to be_nil
end
end
end

0 comments on commit 151ad1c

Please sign in to comment.