summaryrefslogtreecommitdiff
path: root/testing/02-commands-gc.yarn
diff options
context:
space:
mode:
Diffstat (limited to 'testing/02-commands-gc.yarn')
-rw-r--r--testing/02-commands-gc.yarn69
1 files changed, 69 insertions, 0 deletions
diff --git a/testing/02-commands-gc.yarn b/testing/02-commands-gc.yarn
new file mode 100644
index 0000000..d1cff46
--- /dev/null
+++ b/testing/02-commands-gc.yarn
@@ -0,0 +1,69 @@
+<!-- -*- markdown -*- -->
+gc ---- Invoke git gc on your repository (Takes a repo)
+=======================================================
+
+The `gc` command is a basic pass-through to the underlying `git gc` being run
+on the remote repository. Apart from ensuring that the caller has `write`
+access, to a repository which exists, no other checks are done and any spare
+arguments are passed through to `git gc`.
+
+Using `gc` in the simple case
+-----------------------------
+
+So the simple case is that a `gitano-admin` runs `gc` on a repository which
+definitely exists which means they always have the rights to do so.
+
+ SCENARIO Simple case `gc` usage
+
+ GIVEN a standard instance
+ WHEN testinstance adminkey runs gc gitano-admin
+ THEN stderr is empty
+ AND stdout is empty
+
+We can then ensure that if the repository does not exist, we get a useful error
+message back:
+
+ SCENARIO Simple failure case `gc` usage
+
+ GIVEN a standard instance
+ WHEN testinstance adminkey, expecting failure, runs gc something
+ THEN stdout is empty
+ AND stderr contains repository does not exist
+
+Write access checks
+-------------------
+
+A more complex case involves creating a repository to which a user has no write
+permissions and trying to get that user to run `gc` on it.
+
+ SCENARIO Write access checks for `gc` usage
+
+ GIVEN a standard instance
+ AND testinstance has keys called other
+ WHEN testinstance, using adminkey, adds user other, using testinstance other
+ AND testinstance adminkey runs create testrepo
+ AND testinstance other, expecting failure, runs gc testrepo
+ THEN stdout is empty
+ AND stderr contains Ruleset denied action
+
+Passing arguments to `git gc`
+-----------------------------
+
+Any spare arguments given to `gc` are passed through to `git gc` untouched. We
+can verify that arguments are passed through by passing a bad argument through
+and seeing if we get an error message from the underlying `git gc` instance:
+
+ SCENARIO Passing arguments through to `git gc`
+
+ GIVEN a standard instance
+ WHEN testinstance adminkey, expecting failure, runs gc gitano-admin --not-valid
+ THEN stdout is empty
+
+These are the `git gc` errors
+
+ AND stderr contains error: unknown option
+ AND stderr contains usage: git gc
+
+And this demonstrates that Gitano detected the error properly
+
+ AND stderr contains Unable to continue