From patchwork Mon May 20 09:05:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 7788 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 4VjWs62TLgz3wxV for ; Mon, 20 May 2024 09:06:34 +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 4VjWs347Qsz5d1; Mon, 20 May 2024 09:06:31 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VjWs32pMRz331V; Mon, 20 May 2024 09:06:31 +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 4VjWs142Q6z32W4 for ; Mon, 20 May 2024 09:06:29 +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 4VjWs12xKJz3B3; Mon, 20 May 2024 09:06:29 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1716195989; 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=LTcENVS1jjIVPn5ZOCxY2Uz6sou6ozqG28nk6C1grGM=; b=y+FN1nymxYbD248laO5bEEZR4a6r3zgeLOOqDjZgHvFobJASJzkOjZ8/pkFLGFj4MYkhhx kE4uMra3qTwwsVCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1716195989; 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=LTcENVS1jjIVPn5ZOCxY2Uz6sou6ozqG28nk6C1grGM=; b=jgSpC0rnw+VF6ceslIKdafQ1IiEIyTT1N0fGcgxoB3tG8PGTgRaIIcLyVyB5G1QVW22AfB xi3CNumWMtpeQ1dyct8rgSAmA0opM4Km73PGQJFv6lI3cE3Ykp6Rsr+mMmd8S7ubl9F0tR PPnZR7P45/bKFSL+aGlVQo4552HZqMt5JoDMy2oxXgkJbOWVcAImnWi/NHV5//nYAf4ugG gfzjdAIdb1CUi0id+qD27tELjMOOpkSJfagUJfWczBta1ADocUrvbg1i1CT1sakoZ+8uhT 3DT9pC2dlxKsKsAEV04rXVtw49MHt++IpuH3pNcMmj+C1NnUUFDcpV5CTZEiSg== From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH 03/21] tests/lib.sh: Add function test_that_key_in_arry_has_value Date: Mon, 20 May 2024 11:05:53 +0200 Message-Id: <20240520090611.10406-4-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: KEQ7WN5CPTGF6UPP6DW7PHHHC6MCFFFG X-Message-ID-Hash: KEQ7WN5CPTGF6UPP6DW7PHHHC6MCFFFG 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: I think the name says it all. Signed-off-by: Jonatan Schlag --- tests/lib.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/lib.sh b/tests/lib.sh index 7749d5158..c51257e79 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -18,3 +18,17 @@ test_that() { var_has_value() { [[ "${!1}" == "${2}" ]] } + +test_that_key_in_arry_has_value() { + local array="${!1}" + local key="${2}" + local value="${3}" + + if [[ "${array[${key}]}" == "${value}" ]] ; then + echo -e "${CLR_GREEN_BG}Test succeded: The array '${1}' contains the value '${value}' under the key '${key}' ${CLR_RESET}" + return 0 + else + echo -e "${CLR_RED_BG}Test failed: The array '${1}' contains the value '${array[${key}]}' under the key '${key} and not '${value}' ${CLR_RESET}" + return 1 + fi +}