10
from tests import TestCase
11
from utility import temp_dir
14
JUJU_CI_PATH = os.path.join(gotestwin.SCRIPTS, 'jujuci.py')
15
JUJU_HOME = os.path.join(gotestwin.SCRIPTS, '..', 'cloud-city')
18
@contextlib.contextmanager
19
def working_directory(path):
28
class GoTestWinTestCase(TestCase):
30
@patch('subprocess.check_output', return_value='path/foo.tar.gz')
31
@patch('subprocess.check_call')
32
def test_main_with_revision(self, cc_mock, co_mock):
33
with temp_dir() as base:
34
with working_directory(base):
35
gotestwin.main(['host', '1234'])
36
self.assertTrue(os.path.exists('temp-config.yaml'))
37
with open('temp-config.yaml') as f:
40
['python', 'ci/gotesttarfile.py', '-v', '-g', 'go.exe', '-p',
41
'github.com/juju/juju', '--remove', 'ci/foo.tar.gz'],
43
co_mock.assert_called_once_with(
44
[JUJU_CI_PATH, 'get', '-b', '1234', 'build-revision',
47
[JUJU_CI_PATH, 'get-build-vars', '--summary', '1234'])
49
['workspace-run', '-v', '-i', 'cloud-city/staging-juju-rsa',
50
'temp-config.yaml', 'Administrator@host'])
51
self.assertEqual([tarfile_call, gotest_call], cc_mock.call_args_list)
53
@patch('subprocess.check_call')
54
def test_main_with_tarfile_and_package(self, cc_mock):
55
with temp_dir() as base:
56
with working_directory(base):
58
['host', 'bar.tar.gz', 'github.com/juju/juju/cmd'])
59
self.assertTrue(os.path.exists('temp-config.yaml'))
60
with open('temp-config.yaml') as f:
63
['python', 'ci/gotesttarfile.py', '-v', '-g', 'go.exe', '-p',
64
'github.com/juju/juju/cmd', '--remove', 'ci/bar.tar.gz'],
66
cc_mock.assert_called_once_with(
67
['workspace-run', '-v', '-i', 'cloud-city/staging-juju-rsa',
68
'temp-config.yaml', 'Administrator@host'])