Two steps:
1. TestDiffDirectories did not check if the expected only return value
was correct; the intention was there to do so (judging by the
comment "change in order"), but my eye for detail failed me.
2. Reversing the directory comparison in the test revealed bugs in the
comparison code -- in general, it should skip any directory that is
not a directory in the comparator.
To make this easier, the code now keeps track of the expected files it
saw. That means the check for whether an actual file has an expected
counterpart only has two cases, yes or no (rather that trying to
account for whether it's a directory and so on). If a directory was
skipped while scanning the expected files, it won't be in the actual
files anyway.
Signed-off-by: Michael Bridgen <mikeb@weave.works>
It's difficult to test the files comparison if it contains all its own
assertions, since you can only test successes. This commit rewrites
the helper to use a func without assertions, that can be more roundly
tested.
This adds another means of updating files to the package pkg/update/,
in setters.go (and gives the existing file a better name).
In passing, I changed the test util for comparing before/after
updates, in pkg/files/, to give a little more context when comparing
file contents; and, since the comparison between actual and expected
is not symmetrical, I corrected the order of the args in the tests.
This factors out the function that checks directories for equivalence,
and uses it to check that the upstream repo has the expected update
when the controller has pushed its commit.