refactor(readTree): Pass all readTree parameters as function args
Instead of having a mix of depot-passed args (for the filter) and args to the readTree function itself, make everything a single attribute set of arguments passed to the function. This also makes it a bit easier to extend this in the future. Change-Id: I633c1fc96026d137b451bb604ef92be32571a0f5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3498 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
parent
4c4aa8e413
commit
aedde913d1
4 changed files with 53 additions and 24 deletions
|
|
@ -8,7 +8,10 @@ let
|
|||
assertThrows
|
||||
;
|
||||
|
||||
tree-ex = depot.nix.readTree {} ./test-example;
|
||||
tree-ex = depot.nix.readTree {
|
||||
path = ./test-example;
|
||||
args = {};
|
||||
};
|
||||
|
||||
example = it "corresponds to the README example" [
|
||||
(assertEq "third_party attrset"
|
||||
|
|
@ -32,7 +35,10 @@ let
|
|||
"roquefort")
|
||||
];
|
||||
|
||||
tree-tl = depot.nix.readTree {} ./test-tree-traversal;
|
||||
tree-tl = depot.nix.readTree {
|
||||
path = ./test-tree-traversal;
|
||||
args = {};
|
||||
};
|
||||
|
||||
traversal-logic = it "corresponds to the traversal logic in the README" [
|
||||
(assertEq "skip subtree default.nix is read"
|
||||
|
|
@ -82,7 +88,10 @@ let
|
|||
# these each call readTree themselves because the throws have to happen inside assertThrows
|
||||
wrong = it "cannot read these files and will complain" [
|
||||
(assertThrows "this file is not a function"
|
||||
(depot.nix.readTree {} ./test-wrong-not-a-function).not-a-function)
|
||||
(depot.nix.readTree {
|
||||
path = ./test-wrong-not-a-function;
|
||||
args = {};
|
||||
}).not-a-function)
|
||||
# can’t test for that, assertThrows can’t catch this error
|
||||
# (assertThrows "this file is a function but doesn’t have dots"
|
||||
# (depot.nix.readTree {} ./test-wrong-no-dots).no-dots-in-function)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue