This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

first test against conflict behaviour

  • Loading branch information...
technomancy committed Jul 25, 2008
1 parent fa4220a commit 23ef0a93d38cf386f0ff84475f04a2a1af021518
Showing with 14 additions and 3 deletions.
  1. +14 −3 test/test_conspire.rb
View
@@ -25,12 +25,12 @@ class TestConspire < Test::Unit::TestCase
def setup
Gitjour::Application.init(REMOTE_SPACE)
File.open(REMOTE_SPACE + '/file', 'w') { |f| f.puts "hello world." }
- `cd #{REMOTE_SPACE}; git add file; git commit -m "init"`
+ `cd #{REMOTE_SPACE}; git add file; git commit -m "conspire"`
@remote_thread = Thread.new do
Gitjour::Application.serve(REMOTE_SPACE, 'conspiracy-remote-test', 7458)
end
-
+ @remote = Conspire::Conspirator.new('localhost.', '7458')
Conspire.start(LOCAL_SPACE, OpenStruct.new(:port => 7457,
:name => 'conspiracy',
:sync_interval => 0.5))
@@ -55,7 +55,7 @@ def test_discover
def test_sync
# getting random unreproducible failings here
- Conspire.conspirators << Conspire::Conspirator.new('localhost.', '7458')
+ Conspire.conspirators << @remote
Conspire.sync_all
assert_equal ["#{LOCAL_SPACE}/file"], Dir.glob("#{LOCAL_SPACE}/*")
end
@@ -65,4 +65,15 @@ def test_conspirator_set
Conspire.conspirators << Conspire::Conspirator.new('dynabook.', '7458')
assert_equal 1, Conspire.conspirators.size
end
+
+ def test_conflicts
+ @remote.sync(LOCAL_SPACE)
+ assert File.exist?(LOCAL_SPACE + '/file'), "Sync did not pull in file"
+ assert_equal 'hello world.\n', File.read(LOCAL_SPACE + '/file')
+
+ File.open("#{LOCAL_SPACE}/file", 'w') { |f| f.puts "hello conspirators!" }
+ `cd #{LOCAL_SPACE}; git add file; git commit -m "conspire"`
+ @remote.sync(LOCAL_SPACE)
+ assert_equal 'hello conspirators!\n', File.read(LOCAL_SPACE + '/file')
+ end
end

0 comments on commit 23ef0a9

Please sign in to comment.