diff --git a/Namcap/tests/pkgbuild/test_nonuniquesources.py b/Namcap/tests/pkgbuild/test_nonuniquesources.py new file mode 100644 index 0000000..1c6d75c --- /dev/null +++ b/Namcap/tests/pkgbuild/test_nonuniquesources.py @@ -0,0 +1,58 @@ +# +# namcap rules - non-unique sources +# Copyright (C) 2019 James P. Harvey +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +from Namcap.tests.pkgbuild_test import PkgbuildTest +import Namcap.rules.nonuniquesources as module + +class NamcapNonUniqueSourcesTest(PkgbuildTest): + pkgbuild_no_source = """ +pkgname=__namcap_test_uniquesources +pkgver=1.0 +pkgrel=1 +pkgdesc="A package" +arch=('i686' 'x86_64') +url="http://www.example.com/" +license=('GPL') +depends=('glibc') +build() { + true +} +package() { + true +} +""" + + test_valid = PkgbuildTest.valid_tests + + def preSetUp(self): + self.rule = module.nonuniquesources + + def test_unique(self): + r = self.run_on_pkg(self.pkgbuild_no_source + "source=('a' 'b')") + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, []) + self.assertEqual(r.infos, []) + + def test_versioned_non_unique(self): + r = self.run_on_pkg(self.pkgbuild_no_source + "source=('v1.2.3.tar.gz')") + self.assertEqual(r.errors, []) + self.assertEqual(r.warnings, [("non-unique-source-name %s", "v1.2.3.tar.gz")]) + self.assertEqual(r.infos, []) + +# vim: set ts=4 sw=4 noet: