5a2b683138026433401b295158dd51676026bd75

Author: Lennon Day-Reynolds

Date: 2009-02-06 15:36:30 -0800

added testing data + unit tests for patch behavior

diff --git a/test/data/git_patch.diff b/test/data/git_patch.diff new file mode 100644 index 0000000..b3abe11 --- /dev/null +++ b/test/data/git_patch.diff @@ -0,0 +1,19 @@ +diff --git a/makefile b/makefile +new file mode 100644 +index 0000000..af2dfd5 +--- /dev/null ++++ b/makefile +@@ -0,0 +1,4 @@ ++all: helloworld ++ ++helloworld: helloworld.c ++ gcc -o helloworld helloworld.c +diff --git a/ohloh_token b/ohloh_token +index 56a6051..d8263ee 100644 +--- a/ohloh_token ++++ b/ohloh_token +@@ -1 +1 @@ +-1 +\ No newline at end of file ++2 +\ No newline at end of file diff --git a/test/data/hg_patch.diff b/test/data/hg_patch.diff new file mode 100644 index 0000000..4299c03 --- /dev/null +++ b/test/data/hg_patch.diff @@ -0,0 +1,9 @@ +diff --git a/makefile b/makefile +new file mode 100644 +--- /dev/null ++++ b/makefile +@@ -0,0 +1,4 @@ ++all: helloworld ++ ++helloworld: helloworld.c ++ gcc -o helloworld helloworld.c diff --git a/test/data/svn_patch.diff b/test/data/svn_patch.diff new file mode 100644 index 0000000..594c071 --- /dev/null +++ b/test/data/svn_patch.diff @@ -0,0 +1,9 @@ +Index: trunk/makefile +=================================================================== +--- trunk/makefile (revision 0) ++++ trunk/makefile (revision 2) +@@ -0,0 +1,4 @@ ++all: helloworld ++ ++helloworld: helloworld.c ++ gcc -o helloworld helloworld.c diff --git a/test/unit/git_patch_test.rb b/test/unit/git_patch_test.rb new file mode 100644 index 0000000..0ec6629 --- /dev/null +++ b/test/unit/git_patch_test.rb @@ -0,0 +1,14 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class GitPatchTest < Scm::Test + def test_patch_for_commit + with_git_repository('git') do |repo| + commit = repo.verbose_commit('b6e9220c3cabe53a4ed7f32952aeaeb8a822603d') + data = File.read(File.join(DATA_DIR, 'git_patch.diff')) + assert_equal data, repo.patch_for_commit(commit) + end + end + end +end + diff --git a/test/unit/hg_patch_test.rb b/test/unit/hg_patch_test.rb new file mode 100644 index 0000000..af7df91 --- /dev/null +++ b/test/unit/hg_patch_test.rb @@ -0,0 +1,14 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class HgPatchTest < Scm::Test + def test_patch_for_commit + with_hg_repository('hg') do |repo| + commit = repo.verbose_commit(1) + data = File.read(File.join(DATA_DIR, 'hg_patch.diff')) + assert_equal data, repo.patch_for_commit(commit) + end + end + end +end + diff --git a/test/unit/svn_patch_test.rb b/test/unit/svn_patch_test.rb new file mode 100644 index 0000000..c7118a4 --- /dev/null +++ b/test/unit/svn_patch_test.rb @@ -0,0 +1,14 @@ +require File.dirname(__FILE__) + '/../test_helper' + +module Scm::Adapters + class SvnPatchTest < Scm::Test + def test_patch_for_commit + with_svn_repository('svn') do |repo| + commit = repo.verbose_commit(2) + data = File.read(File.join(DATA_DIR, 'svn_patch.diff')) + assert_equal data, repo.patch_for_commit(commit) + end + end + end +end +