def create_command(self, files): command = ['golint'] if go_bin_path('golint'): command = [go_bin_path('golint')] if 'min_confidence' in self.options: command += ['-min_confidence', self.options.get('min_confidence')] command += files return command
def test_process_files_with_config__mocked(self, mock_command): mock_command.return_value = [] config = {'min_confidence': 0.95} tool = Golint(self.problems, config) tool.process_files([self.fixtures[1]]) mock_command.assert_called_with( [go_bin_path('golint'), '-min_confidence', 0.95, self.fixtures[1]], ignore_error=True, split=True)
def test_process_files_with_config__mocked(self, mock_command): mock_command.return_value = [] config = { 'min_confidence': 0.95 } tool = Golint(self.problems, config) tool.process_files([self.fixtures[1]]) mock_command.assert_called_with( [ go_bin_path('golint'), '-min_confidence', 0.95, self.fixtures[1] ], ignore_error=True, split=True)
from lintreview.review import Problems, Comment from lintreview.tools.golint import Golint from lintreview.utils import go_bin_path from unittest import TestCase, skipIf from nose.tools import eq_ from mock import patch golint_missing = not(go_bin_path('golint')) class TestGolint(TestCase): needs_golint = skipIf(golint_missing, 'Needs phpcs') fixtures = [ 'tests/fixtures/golint/no_errors.go', 'tests/fixtures/golint/has_errors.go', 'tests/fixtures/golint/http.go', ] def setUp(self): self.problems = Problems() self.tool = Golint(self.problems) def test_match_file(self): self.assertTrue(self.tool.match_file('test.go')) self.assertTrue(self.tool.match_file('dir/name/test.go')) self.assertFalse(self.tool.match_file('dir/name/test.py')) self.assertFalse(self.tool.match_file('test.php')) self.assertFalse(self.tool.match_file('test.golp'))
def check_dependencies(self): """ See if golint is on the system path. """ return in_path('golint') or go_bin_path('golint')