[namcap,2/4] Add test for non-unique source filenames

Message ID 20190527034922.27316-3-jamespharvey20@gmail.com
State New
Headers show
Series Add a rule against common filenames in source() without overridden name | expand

Commit Message

Emil Velikov via arch-projects May 27, 2019, 3:49 a.m. UTC
Signed-off-by: James P. Harvey <jamespharvey20@gmail.com>
---
 .../tests/pkgbuild/test_nonuniquesources.py   | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 Namcap/tests/pkgbuild/test_nonuniquesources.py

Patch

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 <jamespharvey20@gmail.org>
+#
+#   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: