Skip to content
This repository
Browse code

Skip the git state tests if a dns lookup to github.com fails

This is the quickest clever thing I could think of while running the
unit tests offline in the car during a long road trip.
  • Loading branch information...
commit 8b74360493b9402fb1c7221fc6a3c8e18cadd0f6 1 parent 5b60edc
Jeff Schroeder SEJeff authored

Showing 1 changed file with 16 additions and 3 deletions. Show diff stats Hide diff stats

  1. +16 3 tests/integration/states/git.py
19 tests/integration/states/git.py
@@ -3,6 +3,7 @@
3 3 '''
4 4 import os
5 5 import shutil
  6 +import socket
6 7 import integration
7 8
8 9
@@ -11,6 +12,18 @@ class GitTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
11 12 Validate the git state
12 13 '''
13 14
  15 + def setUp(self):
  16 + super(GitTest, self).setUp()
  17 + self.__domain = 'github.com'
  18 + try:
  19 + if hasattr(socket, 'setdefaulttimeout'):
  20 + # 10 second dns timeout
  21 + socket.setdefaulttimeout(10)
  22 + socket.gethostbyname(self.__domain)
  23 + except socket.error:
  24 + msg = 'error resolving {0}, possible network issue?'
  25 + self.skipTest(msg.format(self.__domain))
  26 +
14 27 def test_latest(self):
15 28 '''
16 29 git.latest
@@ -19,7 +32,7 @@ def test_latest(self):
19 32 try:
20 33 ret = self.run_state(
21 34 'git.latest',
22   - name='https://github.com/saltstack/salt.git',
  35 + name='https://{0}/saltstack/salt.git'.format(self.__domain),
23 36 rev='develop',
24 37 target=name,
25 38 submodules=True
@@ -57,7 +70,7 @@ def test_latest_empty_dir(self):
57 70 try:
58 71 ret = self.run_state(
59 72 'git.latest',
60   - name='https://github.com/saltstack/salt.git',
  73 + name='https://{0}/saltstack/salt.git'.format(self.__domain),
61 74 rev='develop',
62 75 target=name,
63 76 submodules=True
@@ -75,7 +88,7 @@ def test_latest_recursive(self):
75 88 try:
76 89 ret = self.run_state(
77 90 'git.latest',
78   - name='https://github.com/mozilla/zamboni.git',
  91 + name='https://{0}/mozilla/zamboni.git'.format(self.__domain),
79 92 target=name,
80 93 submodules=True
81 94 )

0 comments on commit 8b74360

Please sign in to comment.
Something went wrong with that request. Please try again.