Skip to content

Commit

Permalink
Additional testing for git class.
Browse files Browse the repository at this point in the history
  • Loading branch information
caseydreier committed Jul 12, 2011
1 parent b8beb17 commit b7f0802
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/github_backup.rb
Expand Up @@ -5,6 +5,7 @@
require 'github_backup/configuration'
require 'github_backup/repository'
require 'github_backup/github'
require 'github_backup/git'

module GithubBackup

Expand Down
2 changes: 1 addition & 1 deletion lib/github_backup/git.rb
Expand Up @@ -7,7 +7,7 @@ class Git
# Takes a target_dir string and a Repository class
def initialize(target_dir, repository)
self.target_dir = target_dir
raise "GitHub backup directory, #{self.target_dir}, does not exist!" unless Dir.exists?(self.target_dir)
raise "GitHub backup directory, #{self.target_dir}, does not exist!" unless File.directory?(self.target_dir)

self.repository = repository
end
Expand Down
11 changes: 9 additions & 2 deletions test/git_test.rb
Expand Up @@ -3,15 +3,22 @@
class GithubBackup::GitTest < Test::Unit::TestCase

def setup
@tmp_dir = File.join(File.expand_path(File.dirname(__FILE__), '..', 'tmp'))
Dir.mkdir(@tmp_dir) unless Dir.exists?(@tmp_dir)
@tmp_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp'))
Dir.mkdir(@tmp_dir) unless File.directory?(@tmp_dir)
end

def test_initialize
r = GithubBackup::Repository.new(:ssh_url => 'ssh://git@github.com:test')
git = GithubBackup::Git.new(@tmp_dir, r)
end

def test_initialize_raises_error_if_directory_does_not_exist
r = GithubBackup::Repository.new(:ssh_url => 'ssh://git@github.com:test')
assert_raise RuntimeError do
GithubBackup::Git.new('sdfl9ij390', r)
end
end

def teardown
Dir.delete(@tmp_dir)
end
Expand Down

0 comments on commit b7f0802

Please sign in to comment.