-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: pass in handler_option for github/commit handlers, add case for…
… owner detection
- Loading branch information
1 parent
26c683c
commit 7259a45
Showing
3 changed files
with
70 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
local handler = require("gx.handlers.commit") | ||
local handler_options = { | ||
git_remotes = { "upstream", "origin" }, | ||
} | ||
|
||
describe("commit_handler_does_work", function() | ||
it("doesn't see a hash with < 7 characters", function() | ||
assert.is_nil(handler.handle("v", "1a2b3c")) | ||
assert.is_nil(handler.handle("v", "1a2b3c", handler_options)) | ||
end) | ||
|
||
it("does see a hash with 7 characters", function() | ||
assert.equals( | ||
"https://github.com/chrishrb/gx.nvim/commit/1a2b3c4", | ||
handler.handle("v", "1a2b3c4") | ||
handler.handle("v", "1a2b3c4", handler_options) | ||
) | ||
end) | ||
|
||
it("does see a hash with 10 characters", function() | ||
assert.equals( | ||
"https://github.com/chrishrb/gx.nvim/commit/1a2b3c4d5f", | ||
handler.handle("v", "1a2b3c4d5f") | ||
handler.handle("v", "1a2b3c4d5f", handler_options) | ||
) | ||
end) | ||
|
||
it("does see a hash with 40 characters", function() | ||
local hash = "1a2b3c4d5f1a2b3c4d5f1a2b3c4d5f1a2b3c4d5f" | ||
assert.equals("https://github.com/chrishrb/gx.nvim/commit/" .. hash, handler.handle("v", hash)) | ||
assert.equals( | ||
"https://github.com/chrishrb/gx.nvim/commit/" .. hash, | ||
handler.handle("v", hash, handler_options) | ||
) | ||
end) | ||
|
||
it("doesn't see a hash with > 40 characters", function() | ||
assert.is_nil(handler.handle("v", "1a2b3c4d5f1a2b3c4d5f1a2b3c4d5f1a2b3c4d5fa")) | ||
assert.is_nil(handler.handle("v", "1a2b3c4d5f1a2b3c4d5f1a2b3c4d5f1a2b3c4d5fa", handler_options)) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,43 @@ | ||
local handler = require("gx.handlers.github") | ||
local handler_options = { | ||
git_remotes = { "upstream", "origin" }, | ||
} | ||
|
||
describe("github_handler_does_work", function() | ||
it("with_plain_issue_number", function() | ||
assert.equals("https://github.com/chrishrb/gx.nvim/issues/2", handler.handle("v", "#2")) | ||
assert.equals( | ||
"https://github.com/chrishrb/gx.nvim/issues/2", | ||
handler.handle("v", "#2", handler_options) | ||
) | ||
end) | ||
it("with_text_before_issue_number", function() | ||
assert.equals("https://github.com/chrishrb/gx.nvim/issues/22", handler.handle("v", "Fixes #22")) | ||
assert.equals( | ||
"https://github.com/chrishrb/gx.nvim/issues/22", | ||
handler.handle("v", "Fixes #22", handler_options) | ||
) | ||
end) | ||
it("with_text_after_issue_number", function() | ||
assert.equals( | ||
"https://github.com/chrishrb/gx.nvim/issues/40", | ||
handler.handle("v", "#40 is a related issue") | ||
handler.handle("v", "#40 is a related issue", handler_options) | ||
) | ||
end) | ||
it("with_text_all_around", function() | ||
assert.equals( | ||
"https://github.com/chrishrb/gx.nvim/issues/4", | ||
handler.handle("v", "Fixes #4 once and for all") | ||
handler.handle("v", "Fixes #4 once and for all", handler_options) | ||
) | ||
end) | ||
it("with_issue_number_in_parentheses", function() | ||
assert.equals( | ||
"https://github.com/chrishrb/gx.nvim/issues/51", | ||
handler.handle("v", "This is a squashed PR (#51)") | ||
handler.handle("v", "This is a squashed PR (#51)", handler_options) | ||
) | ||
end) | ||
it("github_issue owner detection", function() | ||
assert.equals( | ||
"https://github.com/foouser/gx.nvim/issues/42", | ||
handler.handle("v", "See foouser#42", handler_options) | ||
) | ||
end) | ||
end) |