Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,11 @@ jobs:
brew unlink python@$python_version && brew link --overwrite python@$python_version

echo == Remove pre-installed azure-cli ==
brew uninstall azure-cli
if brew list --versions azure-cli >/dev/null 2>&1; then
brew uninstall azure-cli
else
echo "azure-cli is not pre-installed"
fi

echo == Install azure-cli.rb formula ==
# Need to create a dummy homebrew tap to install the formula
Expand Down
6 changes: 5 additions & 1 deletion scripts/release/homebrew/test_homebrew_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ set -ev
CLI_VERSION=`cat $SYSTEM_ARTIFACTSDIRECTORY/metadata/version`

echo == Remove pre-installed azure-cli ==
brew uninstall azure-cli
if brew list --versions azure-cli >/dev/null 2>&1; then
brew uninstall azure-cli
else
echo "azure-cli is not pre-installed"
fi
Comment on lines +8 to +12

echo == Install azure-cli.rb formula ==
# TODO(packaging): remove once the macOS CI agent image's Homebrew provides formula_opt_prefix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def download_file(client, destination_path=None, overwrite=True, timeout=None):

with open(destination_path, 'wb') as stream:
download = client.download_file(timeout=timeout)
download_content = download.readall()
stream.write(download_content)
download.readinto(stream)


def exists(cmd, client, timeout=None):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import os
import tempfile
import unittest
from types import SimpleNamespace
from unittest import mock

from azure.cli.command_modules.storage.operations.fs_file import download_file


class TestStorageFsFileOperations(unittest.TestCase):

def test_download_file_streams_content_to_destination(self):
download = mock.Mock()

def _write_to_stream(target_stream):
return target_stream.write(b'hello world')

download.readinto.side_effect = _write_to_stream

client = mock.Mock()
client.get_file_properties.return_value = SimpleNamespace(name='dir/test.txt')
client.download_file.return_value = download

with tempfile.TemporaryDirectory() as temp_dir:
download_file(client, destination_path=temp_dir)

with open(os.path.join(temp_dir, 'test.txt'), 'rb') as downloaded_file:
self.assertEqual(downloaded_file.read(), b'hello world')

download.readinto.assert_called_once()
download.readall.assert_not_called()
Loading