summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2017-03-04 11:01:22 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2017-03-04 16:48:58 +0000
commit00b36703facf94642868ab8dea4785d4e162f3bc (patch)
tree46dcac0d12d12640601d1c069bd4bd90e386a236 /testing
parentd4fdeb550744b17169383f51f62ea126c7b6cc3e (diff)
downloadgitano-00b36703facf94642868ab8dea4785d4e162f3bc.tar.gz
adds testing for treediff/targets
Diffstat (limited to 'testing')
-rw-r--r--testing/03-treedelta-rules.yarn78
-rw-r--r--testing/admin-patches/must-affect-FOO.patch13
-rw-r--r--testing/content-patches/change-a-FOO.patch6
-rw-r--r--testing/content-patches/rename-a-FOO.patch10
4 files changed, 107 insertions, 0 deletions
diff --git a/testing/03-treedelta-rules.yarn b/testing/03-treedelta-rules.yarn
index 699327d..f96524e 100644
--- a/testing/03-treedelta-rules.yarn
+++ b/testing/03-treedelta-rules.yarn
@@ -91,3 +91,81 @@ we do to `target_tree` we can't push...
THEN stderr contains Needs a FOO
FINALLY the instance is torn down
+
+Tree deltas
+-----------
+
+When there are trees in play, the `treediff/targets`, `treediff/added`,
+`treediff/deleted`, `treediff/modified`, `treediff/renamed`, and
+`treediff/renamedto` values end up set.
+
+The _targets_ are any name which shows up in any of _added_, _deleted_,
+_modified_, _renamed_, or _renamedto_. The others are, respectively, the
+names of new tree entries, removed tree entries, entries whose content has
+changed, and then rename detection logic.
+
+> Sadly currently Gitano can't tell which rename from/to is matched with which.
+
+First up, let's ensure that `treediff/targets` works for the various kinds
+of adding, modifying, removing, and renaming operations...
+
+ SCENARIO any change must affect FOO
+ GIVEN a standard instance
+ AND a unix user called alice
+ AND alice has keys called main
+
+ WHEN testinstance, using adminkey, adds user alice, using alice main
+ AND testinstance adminkey runs create testrepo alice
+ AND alice, using main, clones testrepo as testrepo
+ THEN alice testrepo has no file called FOO
+
+ GIVEN testinstance using adminkey has patched gitano-admin with must-affect-FOO.patch
+
+First up, when we try an empty commit we can't push it...
+
+ WHEN alice, using main, expecting failure, pushes an empty commit in testrepo
+ THEN stderr contains Needs a FOO
+
+Next, when a FOO is added, it should turn up in `treediff/targets`
+
+ WHEN alice applies add-a-FOO.patch in testrepo
+ AND alice, using main, pushes testrepo to testrepo.git
+ THEN the output contains new branch
+
+But its mere presence in `start_tree` shouldn't allow empty commits...
+
+ WHEN alice, using main, expecting failure, pushes an empty commit in testrepo
+ THEN stderr contains Needs a FOO
+
+Now we verify that altering the content turns up in `treediff/targets`
+
+ WHEN alice applies change-a-FOO.patch in testrepo
+ AND alice, using main, pushes testrepo to testrepo.git
+ THEN the output contains master -> master
+
+Next, when the FOO gets removed, it should show in `treediff/targets`
+
+ WHEN alice reverts change-a-FOO.patch in testrepo
+ AND alice reverts add-a-FOO.patch in testrepo
+ AND alice, using main, pushes testrepo to testrepo.git
+ THEN the output contains master -> master
+
+Next we need to rename a FOO, to do that, first add it back...
+
+ WHEN alice applies add-a-FOO.patch in testrepo
+ AND alice, using main, pushes testrepo to testrepo.git
+ THEN the output contains master -> master
+
+and then check that renaming the FOO causes it to turn up in `treediff/targets`
+
+ WHEN alice applies rename-a-FOO.patch in testrepo
+ AND alice, using main, pushes testrepo to testrepo.git
+ THEN the output contains master -> master
+
+and finally we ensure that renaming it *back* works too...
+
+ WHEN alice reverts rename-a-FOO.patch in testrepo
+ AND alice, using main, pushes testrepo to testrepo.git
+ THEN the output contains master -> master
+
+ FINALLY the instance is torn down
diff --git a/testing/admin-patches/must-affect-FOO.patch b/testing/admin-patches/must-affect-FOO.patch
new file mode 100644
index 0000000..07c570e
--- /dev/null
+++ b/testing/admin-patches/must-affect-FOO.patch
@@ -0,0 +1,13 @@
+diff --git a/rules/project.lace b/rules/project.lace
+index aafa17c..388766a 100644
+--- a/rules/project.lace
++++ b/rules/project.lace
+@@ -43,6 +43,8 @@ include global:remoteconfigchecks op_is_config
+ # Okay, if we're altering the admin ref, in we go
+ include global:adminchecks is_admin_ref
+
++deny "Needs a FOO" op_is_normal ![treediff/targets is FOO]
++
+ # Now we're into branch operations. Owners can do any normal operation
+ # Normal ops are create/delete/fastforward on refs
+ allow "Owners can create refs" op_is_normal is_owner
diff --git a/testing/content-patches/change-a-FOO.patch b/testing/content-patches/change-a-FOO.patch
new file mode 100644
index 0000000..8c23604
--- /dev/null
+++ b/testing/content-patches/change-a-FOO.patch
@@ -0,0 +1,6 @@
+diff -urN a/FOO b/FOO
+--- a/FOO 2017-03-04 10:49:13.351217763 +0000
++++ b/FOO 2017-03-04 10:49:36.467415444 +0000
+@@ -1 +1,2 @@
+ This is a FOO
++FOO has changed
diff --git a/testing/content-patches/rename-a-FOO.patch b/testing/content-patches/rename-a-FOO.patch
new file mode 100644
index 0000000..1a8e1ae
--- /dev/null
+++ b/testing/content-patches/rename-a-FOO.patch
@@ -0,0 +1,10 @@
+diff -urN a/BAR b/BAR
+--- a/BAR 1970-01-01 01:00:00.000000000 +0100
++++ b/BAR 2017-03-04 10:59:53.488578394 +0000
+@@ -0,0 +1 @@
++This is a FOO
+diff -urN a/FOO b/FOO
+--- a/FOO 2017-03-04 10:59:53.488578394 +0000
++++ b/FOO 1970-01-01 01:00:00.000000000 +0100
+@@ -1 +0,0 @@
+-This is a FOO