Imported Upstream version 17.22.1
[platform/upstream/libzypp.git] / tests / zypp / Vendor_test.cc
1
2 #include <iostream>
3 #include <list>
4 #include <string>
5
6 // Boost.Test
7 #include <boost/test/unit_test.hpp>
8
9 #include "zypp/base/LogControl.h"
10 #include "zypp/base/Logger.h"
11 #include "zypp/base/Exception.h"
12 #include "zypp/ZYpp.h"
13 #include "zypp/VendorAttr.h"
14
15 using boost::unit_test::test_case;
16 using namespace std;
17 using namespace zypp;
18
19 namespace zypp
20 {
21   void reconfigureZConfig( const Pathname & );
22 }
23
24 #define DATADIR (Pathname(TESTS_SRC_DIR) + "/zypp/data/Vendor")
25
26 BOOST_AUTO_TEST_CASE(vendor_empty)
27 {
28   BOOST_REQUIRE( VendorAttr::instance().equivalent("", "") );
29   BOOST_REQUIRE( !VendorAttr::instance().equivalent("a", "") );
30   BOOST_REQUIRE( !VendorAttr::instance().equivalent("", "a") );
31
32   BOOST_REQUIRE( VendorAttr::instance().equivalent( IdString::Null, IdString::Null ) );
33   BOOST_REQUIRE( VendorAttr::instance().equivalent( IdString::Empty, IdString::Null ) );
34   BOOST_REQUIRE( VendorAttr::instance().equivalent( IdString::Null, IdString::Empty ) );
35   BOOST_REQUIRE( VendorAttr::instance().equivalent( IdString::Empty, IdString::Empty ) );
36 }
37
38 BOOST_AUTO_TEST_CASE(vendor_test1)
39 {
40   reconfigureZConfig( DATADIR / "zypp1.conf" );
41   // bsc#1030686: Remove legacy vendor equivalence between 'suse' and 'opensuse'
42   // No vendor definition files has been read. So only suse* vendors are
43   // equivalent
44   BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "suse") );
45   BOOST_REQUIRE( VendorAttr::instance().equivalent("equal", "equal") );
46   BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "SuSE") );
47   BOOST_REQUIRE( !VendorAttr::instance().equivalent("opensuse", "SuSE") );
48   BOOST_REQUIRE( !VendorAttr::instance().equivalent("open", "SuSE") );
49   BOOST_REQUIRE( !VendorAttr::instance().equivalent("nothing", "SuSE") );
50
51   // but "opensuse build service" gets its own class:
52   BOOST_REQUIRE( !VendorAttr::instance().equivalent("opensuse build service", "suse") );
53   BOOST_REQUIRE( !VendorAttr::instance().equivalent("opensuse build service", "opensuse") );
54   // bnc#812608: All opensuse projects get their own class
55   BOOST_REQUIRE( !VendorAttr::instance().equivalent("opensuse-education", "suse") );
56   BOOST_REQUIRE( !VendorAttr::instance().equivalent("opensuse-education", "opensuse") );
57   BOOST_REQUIRE( !VendorAttr::instance().equivalent("opensuse-education", "opensuse build service") );
58 }
59