aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2016-06-11 22:20:04 +0100
committerAdam Spiers <git@adamspiers.org>2018-05-15 13:42:16 +0100
commit2c9d23b0291157eb1096384ff76e0122747b9bdf (patch)
tree524c7b479b65a478c998c28475d52e636b919200 /tests
parent9a741f07167dcb6cc81a8f87036d1ea75c4270d3 (diff)
downloadgit-deps-2c9d23b0291157eb1096384ff76e0122747b9bdf.tar.gz
convert into a proper Python module
Sem-Ver: api-break
Diffstat (limited to 'tests')
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/conftest.py12
-rwxr-xr-xtests/create-repo.sh60
-rw-r--r--tests/test_skeleton.py17
4 files changed, 90 insertions, 0 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..0e79501
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1 @@
+test-repo/
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 0000000..a2dac00
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+ Dummy conftest.py for git_deps.
+
+ If you don't know what this is for, just leave it empty.
+ Read more about conftest.py under:
+ https://pytest.org/latest/plugins.html
+"""
+from __future__ import print_function, absolute_import, division
+
+import pytest
diff --git a/tests/create-repo.sh b/tests/create-repo.sh
new file mode 100755
index 0000000..bfaffe2
--- /dev/null
+++ b/tests/create-repo.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+here=$(dirname $0)
+
+tag () {
+ git tag "$@"
+ echo -n "Hit Enter to continue ..."
+ read
+}
+
+test_repo=$here/test-repo
+
+rm -rf $test_repo
+mkdir $test_repo
+cd $test_repo
+
+git init
+git config user.email git-deps-test@fake.address
+
+# Start with two independently committed files
+
+for f in file-{a,b}; do
+ cat <<EOF > $f
+one
+two
+three
+four
+five
+six
+seven
+eight
+nine
+ten
+EOF
+
+ git add $f
+ git commit -m "create $f"
+ tag $f
+done
+
+# Now start making changes
+
+sed -i 's/three/three a/' file-a
+git commit -am 'file-a: change three to three a'
+tag file-a-three-a # depends on file-a
+
+sed -i 's/three/three a/' file-b
+git commit -am 'file-b: change three to three a'
+tag file-b-three-a # depends on file-b
+
+# Change non-overlapping part of previously changed file
+sed -i 's/eight/eight a/' file-a
+git commit -am 'file-a: change eight to eight a'
+tag file-a-eight-a # depends on file-a
+
+# Change previously changed line
+sed -i 's/three a/three b/' file-a
+git commit -am 'file-a: change three a to three b'
+tag file-a-three-b # depends on file-a-three-a
+
diff --git a/tests/test_skeleton.py b/tests/test_skeleton.py
new file mode 100644
index 0000000..ec2ef23
--- /dev/null
+++ b/tests/test_skeleton.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import pytest
+from git_deps.skeleton import fib
+
+__author__ = "Adam Spiers"
+__copyright__ = "Adam Spiers"
+__license__ = "none"
+
+
+def test_fib():
+ assert fib(1) == 1
+ assert fib(2) == 1
+ assert fib(7) == 13
+ with pytest.raises(AssertionError):
+ fib(-10)