summaryrefslogtreecommitdiff
path: root/test/test-gall.commit.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-gall.commit.lua')
-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)