~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to tests/test_gotesttarfile.py

  • Committer: Curtis Hovey
  • Date: 2016-09-21 17:54:26 UTC
  • mto: This revision was merged to the branch mainline in revision 1612.
  • Revision ID: curtis@canonical.com-20160921175426-hmk3wlxrl1vpfuwr
Poll for the token, whcih might be None.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
        return None, None
25
25
 
26
26
 
27
 
class gotesttarfileTestCase(TestCase):
 
27
class GotesttarfileTestCase(TestCase):
28
28
 
29
29
    def test_run_success(self):
30
30
        env = {'a': 'b'}
69
69
                    returncode = go_test_package(
70
70
                        'github.com/juju/juju', 'go', gopath)
71
71
        self.assertEqual(0, returncode)
72
 
        self.assertEqual(run_mock.call_count, 2)
 
72
        self.assertEqual(run_mock.call_count, 3)
73
73
        args, kwargs = run_mock.call_args_list[0]
74
 
        self.assertEqual((['go', 'test', './...'],), args)
 
74
        self.assertEqual((['go', 'test', '-i', './...'],), args)
 
75
        args, kwargs = run_mock.call_args_list[1]
 
76
        self.assertEqual(
 
77
            (['go', 'test', '-timeout=1200s', './...'],), args)
75
78
        self.assertEqual('amd64', kwargs['env'].get('GOARCH'))
76
79
        self.assertEqual(gopath, kwargs['env'].get('GOPATH'))
77
80
        run_mock.assert_called_with(['sudo', 'killall', '-SIGABRT', 'mongod'])
91
94
                            returncode = go_test_package(
92
95
                                'github.com/juju/juju', 'go', gopath)
93
96
        self.assertEqual(0, returncode)
 
97
        self.assertEqual(run_mock.call_count, 3)
94
98
        args, kwargs = run_mock.call_args_list[0]
95
 
        self.assertEqual(run_mock.call_count, 2)
96
 
        self.assertEqual(
97
 
            (['powershell.exe', '-Command', 'go', 'test', './...'], ),
 
99
        self.assertEqual(
 
100
            (['powershell.exe', '-Command', 'go', 'test', '-i', './...'], ),
 
101
            args)
 
102
        args, kwargs = run_mock.call_args_list[1]
 
103
        self.assertEqual(
 
104
            (['powershell.exe', '-Command', 'go', 'test',
 
105
              '-timeout=1200s', './...'], ),
98
106
            args)
99
107
        self.assertEqual(r'C:\foo;C:\baz', kwargs['env'].get('Path'))
100
108
        self.assertEqual(None, kwargs['env'].get('PATH'))
104
112
        run_mock.assert_called_with(
105
113
            ['taskkill.exe', '/F', '/FI', 'imagename eq mongod.exe'])
106
114
 
 
115
    def test_go_test_package_compile_failure(self):
 
116
        with temp_dir() as gopath:
 
117
            package_path = os.path.join(
 
118
                gopath, 'src', 'github.com', 'juju', 'juju')
 
119
            os.makedirs(package_path)
 
120
            with patch('gotesttarfile.run', return_value=1,
 
121
                       autospec=True) as run_mock:
 
122
                devnull = open(os.devnull, 'w')
 
123
                with patch('sys.stdout', devnull):
 
124
                    returncode = go_test_package(
 
125
                        'github.com/juju/juju', 'go', gopath)
 
126
        self.assertEqual(1, returncode)
 
127
        self.assertEqual(run_mock.call_count, 1)
 
128
        args, kwargs = run_mock.call_args_list[0]
 
129
        self.assertEqual((['go', 'test', '-i', './...'],), args)
 
130
 
107
131
    def test_parse_args(self):
108
132
        args = parse_args(
109
133
            ['-v', '-g', 'go', '-p' 'github/foo', '-r', 'juju.tar.gz'])