From ff22f97d32bdf2933cca34e6f40673b3ba6cad15 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:53:42 +0200 Subject: [PATCH] azure-cli: add tests for cli with extensions/with mutable config Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- pkgs/tools/admin/azure-cli/default.nix | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pkgs/tools/admin/azure-cli/default.nix b/pkgs/tools/admin/azure-cli/default.nix index 89bd83d23a1b..b813506074a0 100644 --- a/pkgs/tools/admin/azure-cli/default.nix +++ b/pkgs/tools/admin/azure-cli/default.nix @@ -4,6 +4,7 @@ , stdenvNoCC , fetchurl , fetchFromGitHub +, runCommand , installShellFiles , python3 @@ -347,6 +348,42 @@ py.pkgs.toPythonApplication (py.pkgs.buildAzureCliPackage rec { passthru = { inherit extensions; withExtensions = extensions: azure-cli.override { withExtensions = extensions; }; + tests = { + # Test the package builds with some extensions configured, and the + # wanted extensions are recognized by the CLI and listed in the output. + azWithExtensions = + let + extensions = with azure-cli.extensions; [ + aks-preview + azure-devops + rdbms-connect + ]; + extensionNames = map (ext: ext.pname) extensions; + az = (azure-cli.withExtensions extensions); + in + runCommand "test-az-with-extensions" { } '' + export HOME=$TMPDIR + ${lib.getExe az} extension list > $out + for ext in ${lib.concatStringsSep " " extensionNames}; do + if ! grep -q $ext $out; then + echo "Extension $ext not found in list" + exit 1 + fi + done + ''; + # Test the package builds with mutable config. + # TODO: Maybe we can install an extension from local python wheel to + # check mutable extension install still works. + azWithMutableConfig = + let + az = azure-cli.override { withImmutableConfig = false; }; + in + runCommand "test-az-with-immutable-config" { } '' + export HOME=$TMPDIR + ${lib.getExe az} --version || exit 1 + touch $out + ''; + }; }; meta = with lib; {