summaryrefslogtreecommitdiff
path: root/testing/02-commands-gc.yarn
blob: d1cff46d55afc9500a7e9060f8087e96bb9ec070 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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