lib/toxiproxy.rb in toxiproxy-0.1.1 vs lib/toxiproxy.rb in toxiproxy-0.1.2

- old
+ new

@@ -87,10 +87,15 @@ def self.populate(*proxies) proxies = proxies.first if proxies.first.is_a?(Array) proxies.map { |proxy| - self.create(proxy) unless find_by_name(proxy[:name]) + existing = find_by_name(proxy[:name]) + if existing && (existing.upstream != proxy[:upstream] || existing.listen != proxy[:listen]) + existing.destroy + existing = false + end + self.create(proxy) unless existing }.compact end # Set an upstream toxic. def upstream(toxic = nil, attrs = {})