From patchwork Sun Jun 16 16:02:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7871 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4W2Hqj4WLqz3x1l for ; Sun, 16 Jun 2024 16:03:29 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4W2Hqf5Y8Xz5gZ; Sun, 16 Jun 2024 16:03:26 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4W2Hqf52M1z33Fy; Sun, 16 Jun 2024 16:03:26 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4W2Hqc4D1Qz33G6 for ; Sun, 16 Jun 2024 16:03:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4W2HqW6hw5z2rM; Sun, 16 Jun 2024 16:03:19 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1718553799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xa/td31rfHus12evJi6wGw+9gZxBdAWE35arV842exE=; b=9CHuT7g3Nmw20XAfTZXIeiEuKcVvh1iJQjgPwzhbZYIco0f/a0Y2DZsRejYZlgHIF10Ui5 kTiNM14n11xeF6DA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1718553799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xa/td31rfHus12evJi6wGw+9gZxBdAWE35arV842exE=; b=faHxgOT+BwqCV1aSBDz1EPXq7+4v48AxxHXAqlev2WFo7kTQZRJyCIXZ0Dc/zrVHoUsC1U 0bzelOp53mFA4PWRmZZm5T1cvW5Kt3Mc4dGt2R1KeuFG17mCHcjw3WVOO+ko2tUPpBpAAJ CBs3x0QP7o/asaEQ8Rs4KCVhNGQAIaeVXVgBWrLDhZJSLAylLxm4G4l5KangxXULdciCrh w4rBXUdlVi93dg2snUT+f3GHGNXUCXyRCIWf/dZohJtSse6AWvt1hphZdarmQgeh3jpA/b m2qFGmrERBM2djqIHXjASTx5mtbxuaTvmc0hSm9W8hYfXccrDv2KUqD99SoXOg== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH v2 09/18] tests: Add functions test_that_array_doesnt_have_key Date: Sun, 16 Jun 2024 18:02:36 +0200 Message-Id: <20240616160245.18865-10-jonatan.schlag@ipfire.org> In-Reply-To: <20240616160245.18865-1-jonatan.schlag@ipfire.org> References: <20240616160245.18865-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 5YDEOPCQ2FM73CZOIIXZHSC7NNDXAGBB X-Message-ID-Hash: 5YDEOPCQ2FM73CZOIIXZHSC7NNDXAGBB X-MailFrom: jonatan.schlag@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Apparently we can set way more keys then I expected. So we need a function to check that we do not set certain key. Some keys need to be skipped. Signed-off-by: Jonatan Schlag --- tests/lib.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/lib.sh b/tests/lib.sh index 32481b6a5..bb06e11c2 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -74,6 +74,24 @@ test_value_in_array() { fi } +test_that_array_doesnt_have_key() { + local -n array="${1}" + local arrayname="${1}" + local key="${2}" + + test_that_array_is_defined "${arrayname}" || return 1 + + if [[ "${array["${key}"]+_}" == "_" ]]; then + log_test_failed "The array '${arrayname}' does contain the key '${key}'." + return 1 + else + log_test_succeded "The array '${arrayname}' does not contain the key '${key}'" + return 0 + fi + +} + + test_that_output_is(){ local reference_output_file="${1}" local file_descriptor="${2}"