blob: 2d8747f1d3070961d525f473cb66bb7672a9c5e1 [file] [log] [blame]
Doug Hellmannc0a088d2015-09-04 18:28:59 +00001#!/usr/bin/env python
2
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
Doug Hellmannc0a088d2015-09-04 18:28:59 +000015import os
16
17import testtools
18import zuul.cmd.cloner
19
Doug Hellmannc0a088d2015-09-04 18:28:59 +000020
21class TestClonerCmdArguments(testtools.TestCase):
22
23 def setUp(self):
24 super(TestClonerCmdArguments, self).setUp()
25 self.app = zuul.cmd.cloner.Cloner()
26
27 def test_default_cache_dir_empty(self):
28 self.app.parse_arguments(['base', 'repo'])
29 self.assertEqual(None, self.app.args.cache_dir)
30
31 def test_default_cache_dir_environ(self):
32 try:
33 os.environ['ZUUL_CACHE_DIR'] = 'fromenviron'
34 self.app.parse_arguments(['base', 'repo'])
35 self.assertEqual('fromenviron', self.app.args.cache_dir)
36 finally:
37 del os.environ['ZUUL_CACHE_DIR']
38
39 def test_default_cache_dir_override_environ(self):
40 try:
41 os.environ['ZUUL_CACHE_DIR'] = 'fromenviron'
42 self.app.parse_arguments(['--cache-dir', 'argument',
43 'base', 'repo'])
44 self.assertEqual('argument', self.app.args.cache_dir)
45 finally:
46 del os.environ['ZUUL_CACHE_DIR']
47
48 def test_default_cache_dir_argument(self):
49 self.app.parse_arguments(['--cache-dir', 'argument',
50 'base', 'repo'])
51 self.assertEqual('argument', self.app.args.cache_dir)