summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorАлексей Шилин <rootlexx@mail.ru>2019-11-25 09:59:38 +0000
committerJulian Andres Klode <jak@debian.org>2019-11-25 09:59:38 +0000
commit19033186919b9c6d31ca3aabaacfb069a4b64f88 (patch)
tree13cc2899b6497f463d401091a9a6b8a603d9d3f3 /test
parent4afb07258fad5f9026ad25f579a871093a312ac5 (diff)
Search in all available description translations
When multiple translations of package descriptions are available, perform search in all of them. It allows using search patterns in any of the configured languages. Previously, only the first available translation was searched. As the result, patterns in e.g. English never matched packages which had their descriptions translated into local language. Closes: #490000
Diffstat (limited to 'test')
-rwxr-xr-xtest/integration/test-bug-490000-search-in-all-translations107
1 files changed, 107 insertions, 0 deletions
diff --git a/test/integration/test-bug-490000-search-in-all-translations b/test/integration/test-bug-490000-search-in-all-translations
new file mode 100755
index 000000000..3a034bc49
--- /dev/null
+++ b/test/integration/test-bug-490000-search-in-all-translations
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "${TESTDIR}/framework"
+
+setupenvironment
+
+ARCH='amd64'
+DIST='unstable'
+
+PKG_NAME='foo'
+PKG_VERSION='1.0'
+
+SHORT_DESCRIPTION_EN='have you fooed today?'
+LONG_DESCRIPTION_EN="${SHORT_DESCRIPTION_EN}
+ Where there's foo, there's fire."
+
+SHORT_DESCRIPTION_ZZ='bar alter ego'
+LONG_DESCRIPTION_ZZ="${SHORT_DESCRIPTION_ZZ}
+ He who foos last foos best."
+
+configure_languages()
+{
+ {
+ echo '#clear Acquire::Languages;'
+ echo 'Acquire::Languages {'
+ for language in "$@"
+ do
+ echo " \"${language}\";"
+ done
+ echo '};'
+ } > rootdir/etc/apt/apt.conf.d/languages.conf
+}
+
+new_translation_record()
+{
+ echo "Package: ${1:?Package name expected}"
+ echo "Description-md5: ${2:?Description-md5 expected}"
+ echo "Description-${3:?Language code expected}: ${4:?Package description expected}"
+ echo
+}
+
+str_md5sum()
+{
+ echo -n "${1:?String expected}" | md5sum | cut -d ' ' -f 1
+}
+
+configarchitecture "${ARCH}"
+
+insertpackage "${DIST}" "${PKG_NAME}" "${ARCH}" "${PKG_VERSION}" '' '' "${LONG_DESCRIPTION_EN}"
+# English translation was already added by insertpackage above
+new_translation_record "${PKG_NAME}" "$(str_md5sum "${LONG_DESCRIPTION_EN}")" 'zz' "${LONG_DESCRIPTION_ZZ}" > "aptarchive/dists/${DIST}/main/i18n/Translation-zz"
+
+configure_languages en zz
+setupaptarchive
+
+# ===========================
+#
+# Tests
+#
+# ===========================
+
+# ----------[ apt ]----------
+
+# Test that all translations are searched, but the short
+# description is in the first configured language
+
+configure_languages en zz
+testequal "${PKG_NAME}/${DIST} ${PKG_VERSION} ${ARCH}
+ ${SHORT_DESCRIPTION_EN}
+" apt -qq search alter ego
+
+configure_languages zz en
+testequal "${PKG_NAME}/${DIST} ${PKG_VERSION} ${ARCH}
+ ${SHORT_DESCRIPTION_ZZ}
+" apt -qq search you today
+
+# Search in configured languages only
+configure_languages zz
+testempty apt -qq search where fire
+
+# Patterns are AND-ed i.e. all must match against a single
+# description translation
+configure_languages en zz
+testempty apt -qq search there best
+
+# -------[ apt-cache ]-------
+
+# Test that all translations are searched, but the short
+# description is in the first configured language
+
+configure_languages en zz
+testequal "${PKG_NAME} - ${SHORT_DESCRIPTION_EN}" aptcache search alter ego
+
+configure_languages zz en
+testequal "${PKG_NAME} - ${SHORT_DESCRIPTION_ZZ}" aptcache search you today
+
+# Search in configured languages only
+configure_languages zz
+testempty aptcache search where fire
+
+# Patterns are AND-ed i.e. all must match against a single
+# description translation
+configure_languages en zz
+testempty aptcache search there best