From afc25ca2a29e676503ef0a7305777e48ec417e2c Mon Sep 17 00:00:00 2001 From: Suyeol Jeon Date: Sat, 17 Oct 2015 04:53:19 +0900 Subject: [PATCH] Add test code for git commit. --- test/test_install.rb | 80 +++++++++++++++++++++++++++++++++++++++++++- test/test_seed.rb | 66 ++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 1 deletion(-) diff --git a/test/test_install.rb b/test/test_install.rb index ed8f820..dee43e3 100644 --- a/test/test_install.rb +++ b/test/test_install.rb @@ -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}" } @@ -14,6 +14,68 @@ 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" @@ -21,6 +83,14 @@ def test_raise_invalid_github_reponame 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 @@ -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 diff --git a/test/test_seed.rb b/test/test_seed.rb index e7648d1..262fa09 100644 --- a/test/test_seed.rb +++ b/test/test_seed.rb @@ -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}" @@ -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" @@ -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}" @@ -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