Make create version tests easier 61/4061/1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 6 Mar 2017 00:30:23 +0000 (19:30 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Mon, 6 Mar 2017 00:39:20 +0000 (19:39 -0500)
This patch allows version tests to simply be placing files into a
directory and comparing the test results from an input pom and an
expected pom.

Also add a test to validate bump order.

Change-Id: Ide4da6f721223bc4d3edab79db9008e4cae730c6
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
13 files changed:
tests/fixtures/version_bump/bump_order/README [new file with mode: 0644]
tests/fixtures/version_bump/bump_order/pom.xml [new file with mode: 0644]
tests/fixtures/version_bump/bump_order/pom.xml.expected [new file with mode: 0644]
tests/fixtures/version_bump/release/README [new file with mode: 0644]
tests/fixtures/version_bump/release/pom.xml [moved from tests/fixtures/pom.xml.expected-release with 100% similarity]
tests/fixtures/version_bump/release/pom.xml.expected [moved from tests/fixtures/pom.xml.expected-release-bump with 100% similarity]
tests/fixtures/version_bump/snapshot/README [new file with mode: 0644]
tests/fixtures/version_bump/snapshot/pom.xml [moved from tests/fixtures/pom.xml with 100% similarity]
tests/fixtures/version_bump/snapshot/pom.xml.expected [moved from tests/fixtures/pom.xml.expected-bump with 100% similarity]
tests/fixtures/version_release/snapshot/README [new file with mode: 0644]
tests/fixtures/version_release/snapshot/pom.xml [new file with mode: 0644]
tests/fixtures/version_release/snapshot/pom.xml.expected [new file with mode: 0644]
tests/test_version.py

diff --git a/tests/fixtures/version_bump/bump_order/README b/tests/fixtures/version_bump/bump_order/README
new file mode 100644 (file)
index 0000000..5e013c7
--- /dev/null
@@ -0,0 +1,5 @@
+This test checks that version bump order is maintained:
+
+1) bump date-based versions
+2) bump -SNAPSHOT versions
+3) bump -RELEASE versions
diff --git a/tests/fixtures/version_bump/bump_order/pom.xml b/tests/fixtures/version_bump/bump_order/pom.xml
new file mode 100644 (file)
index 0000000..958e72c
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.linuxfoundation.releng</groupId>
+  <artifactId>test-artifact</artifactId>
+  <version>1.0.0-TestRelease</version>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.opendaylight.mdsal.model</groupId>
+        <artifactId>yang-ext</artifactId>
+        <version>2013.09.07.10-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+          <groupId>org.opendaylight.mdsal.model</groupId>
+          <artifactId>general-entity</artifactId>
+          <version>0.10.0-SNAPSHOT</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+</project>
diff --git a/tests/fixtures/version_bump/bump_order/pom.xml.expected b/tests/fixtures/version_bump/bump_order/pom.xml.expected
new file mode 100644 (file)
index 0000000..f6bf923
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.linuxfoundation.releng</groupId>
+  <artifactId>test-artifact</artifactId>
+  <version>1.0.1-SNAPSHOT</version>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.opendaylight.mdsal.model</groupId>
+        <artifactId>yang-ext</artifactId>
+        <version>2013.09.07.11.0-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+          <groupId>org.opendaylight.mdsal.model</groupId>
+          <artifactId>general-entity</artifactId>
+          <version>0.11.0-SNAPSHOT</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+</project>
diff --git a/tests/fixtures/version_bump/release/README b/tests/fixtures/version_bump/release/README
new file mode 100644 (file)
index 0000000..c228203
--- /dev/null
@@ -0,0 +1,2 @@
+This test checks that a release artifact is version bumped by
+x.y.(z+1)-SNAPSHOT when version bump is performed.
diff --git a/tests/fixtures/version_bump/snapshot/README b/tests/fixtures/version_bump/snapshot/README
new file mode 100644 (file)
index 0000000..5cc53b9
--- /dev/null
@@ -0,0 +1,2 @@
+This test checks that a SNAPSHOT artifact is properly bumped by
+x.(y+1).z-SNAPSHOT when version bump is run.
diff --git a/tests/fixtures/version_release/snapshot/README b/tests/fixtures/version_release/snapshot/README
new file mode 100644 (file)
index 0000000..de8d05e
--- /dev/null
@@ -0,0 +1,2 @@
+This test checks that SNAPSHOT artifacts properly get converted to a
+RELEASE_TAG as passed in by the user.
diff --git a/tests/fixtures/version_release/snapshot/pom.xml b/tests/fixtures/version_release/snapshot/pom.xml
new file mode 100644 (file)
index 0000000..0b4d73d
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.linuxfoundation.releng</groupId>
+  <artifactId>test-artifact</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+</project>
diff --git a/tests/fixtures/version_release/snapshot/pom.xml.expected b/tests/fixtures/version_release/snapshot/pom.xml.expected
new file mode 100644 (file)
index 0000000..f8769e3
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.linuxfoundation.releng</groupId>
+  <artifactId>test-artifact</artifactId>
+  <version>1.0.0-TestRelease</version>
+</project>
index 9d8fe84..09e5b3f 100644 (file)
@@ -16,29 +16,26 @@ FIXTURE_DIR = os.path.join(
 
 
 @pytest.mark.datafiles(
-    os.path.join(FIXTURE_DIR, 'pom.xml'),
-    os.path.join(FIXTURE_DIR, 'pom.xml.expected-bump'),
+    os.path.join(FIXTURE_DIR, 'version_bump'),
     )
 def test_version_bump(cli_runner, datafiles):
     os.chdir(datafiles)
-
-    # Version bump should bump versions by x.(y+1).z
     result = cli_runner.invoke(cli.cli, ['version', 'bump', 'TestRelease'])
-    assert filecmp.cmp('pom.xml', 'pom.xml.expected-bump')
+
+    for _file in datafiles.listdir():
+        pom = str(_file) + '/pom.xml'
+        expected_pom = str(_file) + '/pom.xml.expected'
+        assert filecmp.cmp(pom, expected_pom)
 
 
 @pytest.mark.datafiles(
-    os.path.join(FIXTURE_DIR, 'pom.xml'),
-    os.path.join(FIXTURE_DIR, 'pom.xml.expected-release'),
-    os.path.join(FIXTURE_DIR, 'pom.xml.expected-release-bump'),
+    os.path.join(FIXTURE_DIR, 'version_release'),
     )
 def test_version_release(cli_runner, datafiles):
     os.chdir(datafiles)
-
-    # Version release should modify SNAPSHOT to TestRelease
     result = cli_runner.invoke(cli.cli, ['version', 'release', 'TestRelease'])
-    assert filecmp.cmp('pom.xml', 'pom.xml.expected-release')
 
-    # Post release bump should bump versions by x.y.(z+1) and revert back to SNAPSHOT
-    result = cli_runner.invoke(cli.cli, ['version', 'bump', 'TestRelease'])
-    assert filecmp.cmp('pom.xml', 'pom.xml.expected-release-bump')
+    for _file in datafiles.listdir():
+        pom = str(_file) + '/pom.xml'
+        expected_pom = str(_file) + '/pom.xml.expected'
+        assert filecmp.cmp(pom, expected_pom)