Add Product file tests
authorMichael Andres <ma@suse.de>
Thu, 6 Nov 2008 16:40:08 +0000 (16:40 +0000)
committerMichael Andres <ma@suse.de>
Thu, 6 Nov 2008 16:40:08 +0000 (16:40 +0000)
tests/parser/CMakeLists.txt
tests/parser/ProductFileReader_test.cc [new file with mode: 0644]
tests/parser/ProductFileReader_test.dat [new file with mode: 0644]

index b236bfd..62aba6c 100644 (file)
@@ -1,3 +1,6 @@
 ADD_SUBDIRECTORY( yum )
 ADD_SUBDIRECTORY( inifile )
 ADD_SUBDIRECTORY(ws)
+
+ADD_TESTS( ProductFileReader )
+
diff --git a/tests/parser/ProductFileReader_test.cc b/tests/parser/ProductFileReader_test.cc
new file mode 100644 (file)
index 0000000..6c7cd18
--- /dev/null
@@ -0,0 +1,39 @@
+#include "TestSetup.h"
+#include <zypp/parser/ProductFileReader.h>
+
+#define LABELED(V) #V << ":\t" << V
+
+//static TestSetup test( Arch_x86_64 );
+
+// Must be the first test!
+BOOST_AUTO_TEST_CASE(basic)
+{
+  parser::ProductFileData data;
+  BOOST_CHECK( data.empty() );
+
+  data = parser::ProductFileReader::scanFile( TESTS_SRC_DIR "/parser/ProductFileReader_test.dat" );
+  BOOST_REQUIRE( ! data.empty() );
+
+  BOOST_CHECK_EQUAL( data.vendor(), "Novell" );
+  BOOST_CHECK_EQUAL( data.name(), "SUSE_SLES" );
+  BOOST_CHECK_EQUAL( data.edition(), "11-0" );
+  BOOST_CHECK_EQUAL( data.arch(), Arch_i586 );
+  BOOST_CHECK_EQUAL( data.productline(), "" );
+  BOOST_CHECK_EQUAL( data.registerTarget(), "sle-11-i586" );
+  BOOST_CHECK_EQUAL( data.registerRelease(), "whatever" );
+  BOOST_CHECK_EQUAL( data.updaterepokey(), "A43242DKD" );
+
+  BOOST_CHECK_EQUAL( data.upgrades().size(), 2 );
+
+  BOOST_CHECK_EQUAL( data.upgrades()[0].name(), "openSUSE_11.1" );
+  BOOST_CHECK_EQUAL( data.upgrades()[0].summary(), "openSUSE 11.1" );
+  BOOST_CHECK_EQUAL( data.upgrades()[0].repository(), "http://download.opensuse.org/distribution/openSUSE/11.1" );
+  BOOST_CHECK_EQUAL( data.upgrades()[0].notify(), true );
+  BOOST_CHECK_EQUAL( data.upgrades()[0].status(), "stable" );
+
+  BOOST_CHECK_EQUAL( data.upgrades()[1].name(), "openSUSE_Factory" );
+  BOOST_CHECK_EQUAL( data.upgrades()[1].summary(), "openSUSE Factory" );
+  BOOST_CHECK_EQUAL( data.upgrades()[1].repository(), "http://download.opensuse.org/distribution/openSUSE/Factory" );
+  BOOST_CHECK_EQUAL( data.upgrades()[1].notify(), false );
+  BOOST_CHECK_EQUAL( data.upgrades()[1].status(), "unstable" );
+}
diff --git a/tests/parser/ProductFileReader_test.dat b/tests/parser/ProductFileReader_test.dat
new file mode 100644 (file)
index 0000000..e57bc1d
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<product schemeversion="0">
+    <vendor>Novell</vendor>
+    <name>SUSE_SLES</name>
+    <version>11</version>
+    <release>0</release>
+    <arch>i586</arch>
+    <updaterepokey>A43242DKD</updaterepokey>
+    <summary>SUSE Linux Enterprise Server</summary>
+    <description>
+This is the Server product of the SUSE Linux Enterprise edition. It is an alternative product for the Windows Server and other UNIX Operating Systems, providing Server functionality and interoperability with UNIX servers. This is the replacement product intended to sunset SUSE Linux Enterprise Server10 which was introduced in May of 2006
+       The SUSE Linux Enterprise Server 11 addresses very large enterprises as well as         large   enterprises and in some ways also medium, small, government and educational needs for a         secure, stable, reliable and high-performance operating system platform.
+       It is the core and base offering to provide a general-purpose infrastructure solution.  This    offering is engineered, tested and proven to handle mission-critical workloads in the data      center.
+       Developed and backed by Novell, only SUSE Linux Enterprise Server offers an open, scalable,     high-performance data center solution that comes with application security, virtualization and  Integrated systems management across a range of hardware architectures.
+       SUSE Linux Enterprise Server is deployable as a general-purpose server or can be tailored to    run a variety of specialized workloads, and it offers seamless interoperability with your       existing data center infrastructure.
+    </description>
+    <urls>
+      <url name="releasenotes">http://www.novell.com/linux/releasenotes/i586/SUSE-SLES/11/release-notes-sles.rpm</url>
+    </urls>
+
+    <upgrades>
+       <upgrade>
+         <name>openSUSE_11.1</name>
+         <summary>openSUSE 11.1</summary>
+         <repository>http://download.opensuse.org/distribution/openSUSE/11.1</repository>
+         <notify>true</notify>
+         <status>stable</status>
+       </upgrade>
+       <upgrade>
+         <name>openSUSE_Factory</name>
+         <summary>openSUSE Factory</summary>
+         <repository>http://download.opensuse.org/distribution/openSUSE/Factory</repository>
+         <notify>no</notify>
+         <status>unstable</status>
+       </upgrade>
+    </upgrades>
+
+    <register>
+        <target>sle-11-i586</target>
+        <release>whatever</release>
+    </register>
+    <buildconfig>
+        <!-- This section is needed to generate the installation media -->
+        <producttheme>SLES</producttheme>
+        <allowresolving>false</allowresolving>
+     </buildconfig>
+     <installconfig>
+        <!-- All flags needed during installation -->
+        <defaultlang>en_US</defaultlang>
+        <!-- needed for current content file -->
+        <datadir>suse</datadir>
+        <descrdir>suse/setup/descr</descrdir>
+        <references name="sles-release" version="11"/>
+        <distribution>SUSE_SLE</distribution>
+     </installconfig>
+     <runtimeconfig>
+        <!-- All Flags needed in the running system -->
+     </runtimeconfig>
+</product>