summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-09-08 17:45:44 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-09-08 17:45:44 +0100
commite4331d213e31f26dfc1e4bde0810732618f6346d (patch)
tree09f180c7468e034801d42b9697686e60036fffba /test
parentb80edbf10b277115c97a28354a88da97f74d0767 (diff)
downloadgall-e4331d213e31f26dfc1e4bde0810732618f6346d.tar.gz
GALL.COMMIT: Test commit creation
Diffstat (limited to 'test')
-rw-r--r--test/test-gall.commit.lua196
1 files changed, 196 insertions, 0 deletions
diff --git a/test/test-gall.commit.lua b/test/test-gall.commit.lua
index dfb5454..8fd6ed0 100644
--- a/test/test-gall.commit.lua
+++ b/test/test-gall.commit.lua
@@ -91,6 +91,202 @@ function suite.commit_signature()
assert(sig)
end
+function suite.commit_create()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ author = {
+ realname = "Test Author",
+ email = "author@test"
+ },
+ committer = {
+ realname = "Test Committer",
+ email = "committer@test"
+ },
+ message = "NEWCOMMIT",
+ parents = { head },
+ }
+ local newcommit = assert(gall.commit.create(repo, commitinfo))
+end
+
+function suite.commit_create_no_parents_ok()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ author = {
+ realname = "Test Author",
+ email = "author@test"
+ },
+ committer = {
+ realname = "Test Committer",
+ email = "committer@test"
+ },
+ message = "NEWCOMMIT",
+ }
+ local newcommit = assert(gall.commit.create(repo, commitinfo))
+end
+
+function suite.commit_create_bad_no_tree()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ }
+ local ok, msg = gall.commit.create(repo, commitinfo)
+ assert(not ok)
+ assert(msg:find("No tree"))
+end
+
+function suite.commit_create_bad_no_author()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ }
+ local ok, msg = gall.commit.create(repo, commitinfo)
+ assert(not ok)
+ assert(msg:find("No author"))
+end
+
+function suite.commit_create_bad_no_committer()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ author = {},
+ }
+ local ok, msg = gall.commit.create(repo, commitinfo)
+ assert(not ok)
+ assert(msg:find("No committer"))
+end
+
+function suite.commit_create_bad_no_author_name()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ author = {},
+ committer = {},
+ }
+ local ok, msg = gall.commit.create(repo, commitinfo)
+ assert(not ok)
+ assert(msg:find("No author name"))
+end
+
+function suite.commit_create_bad_no_author_email()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ author = { realname = "Author" },
+ committer = {},
+ }
+ local ok, msg = gall.commit.create(repo, commitinfo)
+ assert(not ok)
+ assert(msg:find("No author email"))
+end
+
+function suite.commit_create_bad_no_committer_name()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ author = { realname = "Author", email = "author@foo" },
+ committer = {},
+ }
+ local ok, msg = gall.commit.create(repo, commitinfo)
+ assert(not ok)
+ assert(msg:find("No committer name"))
+end
+
+function suite.commit_create_bad_no_committer_email()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ author = { realname = "Author", email = "author@foo" },
+ committer = { realname = "Committer" },
+ }
+ local ok, msg = gall.commit.create(repo, commitinfo)
+ assert(not ok)
+ assert(msg:find("No committer email"))
+end
+
+function suite.commit_create_bad_no_message()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ author = {
+ realname = "Test Author",
+ email = "author@test"
+ },
+ committer = {
+ realname = "Test Committer",
+ email = "committer@test"
+ },
+ parents = { head },
+ }
+ local ok, msg = gall.commit.create(repo, commitinfo)
+ assert(not ok)
+ assert(msg:find("No message"))
+end
+
+function suite.commit_create_bad_parent_no_sha()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ author = {
+ realname = "Test Author",
+ email = "author@test"
+ },
+ committer = {
+ realname = "Test Committer",
+ email = "committer@test"
+ },
+ message = "NEWCOMMIT",
+ parents = { {} },
+ }
+ local ok, msg = gall.commit.create(repo, commitinfo)
+ assert(not ok)
+ assert(msg:find("had no sha"))
+end
+
+function suite.commit_create_bad_parent_bad_sha()
+ local repo = test_repo()
+ local head = repo:get("HEAD").content
+ local tree = head.tree
+ local commitinfo = {
+ tree = tree,
+ author = {
+ realname = "Test Author",
+ email = "author@test"
+ },
+ committer = {
+ realname = "Test Committer",
+ email = "committer@test"
+ },
+ message = "NEWCOMMIT",
+ parents = { { sha = "BADSHA" } },
+ }
+ local ok, msg = gall.commit.create(repo, commitinfo)
+ assert(not ok)
+ assert(msg:find("BADSHA"))
+end
+
local count_ok = 0
for _, testname in ipairs(testnames) do
-- print("Run: " .. testname)