-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* generalize the args * make public * create tests * point to the tests * move the tests * break out the tests * change the order * simplify * change the names * use the global * add additional case * switch f and F
- Loading branch information
Showing
2 changed files
with
123 additions
and
30 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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
local gh = require "octo.gh" | ||
local eq = assert.are.same | ||
|
||
describe("insert_args:", function() | ||
it("true booleans show up as flags", function() | ||
local args = {} | ||
local opts = { | ||
slurp = false, | ||
paginate = true, | ||
} | ||
gh.insert_args(args, opts) | ||
local expected = { | ||
"--paginate", | ||
} | ||
eq(args, expected) | ||
end) | ||
it("single characters have single hyphen", function() | ||
local args = {} | ||
local opts = { | ||
F = { | ||
query = "query", | ||
}, | ||
} | ||
gh.insert_args(args, opts) | ||
local expected = { | ||
"-F", | ||
"query=query", | ||
} | ||
eq(args, expected) | ||
end) | ||
it("non-single changes have two hyphens", function() | ||
local args = {} | ||
local opts = { | ||
jq = ".", | ||
} | ||
gh.insert_args(args, opts) | ||
local expected = { | ||
"--jq", | ||
".", | ||
} | ||
eq(args, expected) | ||
end) | ||
it("list of fields get brackets", function() | ||
local args = {} | ||
local opts = { | ||
f = { | ||
items = { "a", "b", "c" }, | ||
}, | ||
} | ||
gh.insert_args(args, opts) | ||
local expected = { | ||
"-f", | ||
"items[]=a", | ||
"-f", | ||
"items[]=b", | ||
"-f", | ||
"items[]=c", | ||
} | ||
eq(args, expected) | ||
end) | ||
it("integer values", function() | ||
local args = {} | ||
local opts = { | ||
f = { | ||
num_issues = 15, | ||
}, | ||
} | ||
gh.insert_args(args, opts) | ||
local expected = { | ||
"-f", | ||
"num_issues=15", | ||
} | ||
eq(args, expected) | ||
end) | ||
end) |