From patchwork Mon May 20 09:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7798 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 4VjWsm6Djzz3wxG for ; Mon, 20 May 2024 09:07:08 +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 4VjWsX3dNZz5gB; Mon, 20 May 2024 09:06:56 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWsJ3blKz3374; Mon, 20 May 2024 09:06:44 +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 4VjWsG1C7Cz2y2N for ; Mon, 20 May 2024 09:06:42 +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 4VjWsC1XHDz5N; Mon, 20 May 2024 09:06:39 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195999; 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=oyeu0SQsdW6glOrtO8h6e/8HKLwcXzXJvm+lAh9rnhE=; b=RrgqDhVSn4/qxU7H2ZjXRvp9nuzEiE5ibY8b7wmOBfZhgplRYyd0yvL+6QmpPPOwXKCBVZ OwnlQEySZ5FwjiDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195999; 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=oyeu0SQsdW6glOrtO8h6e/8HKLwcXzXJvm+lAh9rnhE=; b=F3xLewPO+ilqQoWcnUHYnZh335Mg3rI7A9qv8uPYcNBJQidlxjuQ4hRlYmrGYBKZx50l9d GsFzHbLQuP+f8Xw86UeSvC84k2tmwmx2KYbeoZo5oRJMdMX8+e8JgCOjQLdRlEaFhi1TMN 5fYhmbNaRUVndnYdkDX7QIqEFiXKY5fn9DndZnhoRojh0DVGqSOevC9Ovghae18+8+c11u UiCPOJ63hSLCo4NlUtZqnB/f4Der/Ac8XnYDcqzl47jfDQHcgy9CPU7bxSNhztIwk4uGr+ zHUQSciUNCM4pLLR7ArEN6vGL2eWhJ2NDCSAc3cKK1DdU6ZgTSSfr4ZOts3KTA== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 15/21] tests: Add functions test_that_array_doesnt_have_key Date: Mon, 20 May 2024 11:06:05 +0200 Message-Id: <20240520090611.10406-16-jonatan.schlag@ipfire.org> In-Reply-To: <20240520090611.10406-1-jonatan.schlag@ipfire.org> References: <20240520090611.10406-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 6BVJAHEHBYKJUMPFUVKAWBJQNOG4PL2Z X-Message-ID-Hash: 6BVJAHEHBYKJUMPFUVKAWBJQNOG4PL2Z 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 29f4e3b71..1eab92cf7 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -61,6 +61,24 @@ test_that_key_in_arry_has_value() { 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}"