# Path: tests/const.py
# DOCKER_IMAGE = 'debian:10'


from .utils import *
from unittest import mock
from pathlib import Path
from tempfile import TemporaryFile, NamedTemporaryFile
from pwd import getpwuid
from grp import getgrgid
from .const import DOCKER_IMAGE
import pytest
import warnings
import logging
import os
import sys
import subprocess
import shlex
import scuba.__main__ as main
import scuba.constants
import scuba.dockerutil
import scuba
import re
        def mocked_gic(*args, **kw):
            raise scuba.dockerutil.DockerError('mock error')

        # http://alexmarandon.com/articles/python_mock_gotchas/#patching-in-the-wrong-place
        # http://www.voidspace.org.uk/python/mock/patch.html#where-to-patch
        with mock.patch('scuba.scuba.get_image_command', side_effect=mocked_gic):
            # DockerError -> exit(128)
            self.run_scuba([], 128)


    def test_config_error(self):
        '''Verify config errors are handled gracefully'''

        with open('.scuba.yml', 'w') as f:
            f.write('invalid_key: is no good\n')

        # ConfigError -> exit(128)
        self.run_scuba([], 128)

    def test_multiline_alias_no_args_error(self):
        '''Verify config errors from passing arguments to multi-line alias are caught'''
        with open('.scuba.yml', 'w') as f:
            f.write('''
                image: {image}
                aliases:
                  multi:
                    script:
                      - echo multi
                      - echo line
                      - echo alias

# Path: tests/const.py
# DOCKER_IMAGE = 'debian:10'


# Path: tests/test_main.py
from .utils import *
from unittest import mock
from pathlib import Path
from tempfile import TemporaryFile, NamedTemporaryFile
from pwd import getpwuid
from grp import getgrgid
from .const import DOCKER_IMAGE
import pytest
import warnings
import logging
import os
import sys
import subprocess
import shlex
import scuba.__main__ as main
import scuba.constants
import scuba.dockerutil
import scuba
import re

        def mocked_gic(*args, **kw):
            raise scuba.dockerutil.DockerError('mock error')

        # http://alexmarandon.com/articles/python_mock_gotchas/#patching-in-the-wrong-place
        # http://www.voidspace.org.uk/python/mock/patch.html#where-to-patch
        with mock.patch('scuba.scuba.get_image_command', side_effect=mocked_gic):
            # DockerError -> exit(128)
            self.run_scuba([], 128)


    def test_config_error(self):
        '''Verify config errors are handled gracefully'''

        with open('.scuba.yml', 'w') as f:
            f.write('invalid_key: is no good\n')

        # ConfigError -> exit(128)
        self.run_scuba([], 128)

    def test_multiline_alias_no_args_error(self):
        '''Verify config errors from passing arguments to multi-line alias are caught'''
        with open('.scuba.yml', 'w') as f:
            f.write('''
                image: {image}
                aliases:
                  multi:
                    script:
                      - echo multi
                      - echo line
                      - echo alias

                '''.format(image=DOCKER_IMAGE))