Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

Commit

Permalink
Add test code for git commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
devxoul committed Oct 16, 2015
1 parent 102e8a6 commit afc25ca
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 1 deletion.
80 changes: 79 additions & 1 deletion test/test_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class InstallTest < Test

def test_install_github
def test_github_version
seedfile %{
github "devxoul/JLToast", "1.2.2", :files => "JLToast/*.{h,swift}"
}
Expand All @@ -14,13 +14,83 @@ def test_install_github
end


def test_github_commit_1
seedfile %{
github "devxoul/SwipeBack", :commit => "534a677"
}
@seed.install

dir = File.join(@seeds_dirname, "SwipeBack")

assert\
File.exists?(dir),
"Directory Seeds/SwipeBack not exists."

refute\
File.exists?(File.join(dir, "SwipeBack/SwipeBack.h")),
"File Seeds/SwipeBack/SwipeBack/SwipeBack.h should not exist."
end


def test_github_commit_2
seedfile %{
github "devxoul/SwipeBack", :commit => "90b256"
}
@seed.install

dir = File.join(@seeds_dirname, "SwipeBack")

assert\
File.exists?(dir),
"Directory Seeds/SwipeBack not exists."

assert\
File.exists?(File.join(dir, "SwipeBack/SwipeBack.h")),
"File Seeds/SwipeBack/SwipeBack/SwipeBack.h does not exist."
end


def test_github_update
path = File.join(@seeds_dirname, "SwiftyImage/SwiftyImage/SwiftyImage.h")

seedfile %{
github "devxoul/SwiftyImage", :commit => "af84dbd"
}
@seed.install
refute File.exists?(path),
"File Seeds/SwiftyImage/SwiftyImage/SwiftyImage.h should not exist."

seedfile %{
github "devxoul/SwiftyImage", :commit => "8b0c07a"
}
@seed.install
assert File.exists?(path),
"File Seeds/SwiftyImage/SwiftyImage/SwiftyImage.h does not exist."

seedfile %{
github "devxoul/SwiftyImage", :commit => "af84dbd"
}
@seed.install
refute File.exists?(path),
"File Seeds/SwiftyImage/SwiftyImage/SwiftyImage.h should not exist."
end


def test_raise_invalid_github_reponame
seedfile %{
github "JLToast", "1.2.2"
}
assert_raises Seeds::Exception do @seed.install end
end


def test_raise_github_both_tag_and_commit
seedfile %{
github "JLToast", "1.2.2", :commit => "83a1b50"
}
assert_raises Seeds::Exception do @seed.install end
end

end


Expand All @@ -45,4 +115,12 @@ def test_raise_invalid_bitbucket_reponame
assert_raises Seeds::Exception do @seed.install end
end


def test_raise_bitbucket_both_tag_and_commit
seedfile %{
bitbucket "JLToast", "1.2.2", :commit => "83a1b50"
}
assert_raises Seeds::Exception do @seed.install end
end

end
66 changes: 66 additions & 0 deletions test/test_seed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ def test_github_version
end


def test_github_commit
seedfile %{
github "devxoul/JLToast", :commit => "83a1b50153ed26f0ae0e90d65"
}
@seed.prepare_requirements
@seed.execute_seedfile
s = @seed.seeds["JLToast"]
assert_equal s.name, "JLToast"
assert_nil s.version
assert_equal s.commit, "83a1b50"
assert_equal s.url, "https://github.com/devxoul/JLToast"
end


def test_github_version_and_files
seedfile %{
github "devxoul/JLToast", "1.3.2", :files => "JLToast/*.{h,swift}"
Expand Down Expand Up @@ -44,6 +58,27 @@ def test_github_version_and_files_array
end


def test_github_commit_and_files
seedfile %{
github "devxoul/JLToast",
:commit => "83a1b50",
:files => "JLToast/*.{h,swift}"
}
@seed.prepare_requirements
@seed.execute_seedfile
s = @seed.seeds["JLToast"]
assert_equal s.name, "JLToast"
assert_nil s.version
assert_equal s.commit, "83a1b50"
assert_equal s.url, "https://github.com/devxoul/JLToast"
assert_equal s.files, ["JLToast/*.{h,swift}"]
end

end


class SeedTest

def test_bitbucket_version
seedfile %{
bitbucket "devxoul/JLToast", "1.3.2"
Expand All @@ -57,6 +92,20 @@ def test_bitbucket_version
end


def test_bitbucket_commit
seedfile %{
github "devxoul/JLToast", :commit => "83a1b50"
}
@seed.prepare_requirements
@seed.execute_seedfile
s = @seed.seeds["JLToast"]
assert_equal s.name, "JLToast"
assert_nil s.version
assert_equal s.commit, "83a1b50"
assert_equal s.url, "https://github.com/devxoul/JLToast"
end


def test_bitbucket_version_and_files
seedfile %{
bitbucket "devxoul/JLToast", "1.3.2", :files => "JLToast/*.{h,swift}"
Expand Down Expand Up @@ -85,4 +134,21 @@ def test_bitbucket_version_and_files_array
assert_equal s.files, ["JLToast/JLToast.h", "JLToast/JLToast.swift"]
end


def test_bitbucket_commit_and_files
seedfile %{
github "devxoul/JLToast",
:commit => "83a1b50",
:files => "JLToast/*.{h,swift}"
}
@seed.prepare_requirements
@seed.execute_seedfile
s = @seed.seeds["JLToast"]
assert_equal s.name, "JLToast"
assert_nil s.version
assert_equal s.commit, "83a1b50"
assert_equal s.url, "https://github.com/devxoul/JLToast"
assert_equal s.files, ["JLToast/*.{h,swift}"]
end

end

0 comments on commit afc25ca

Please sign in to comment.