|
| 1 | +package common |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "testing" |
| 6 | + |
| 7 | + . "gopkg.in/check.v1" |
| 8 | +) |
| 9 | + |
| 10 | +func Test(t *testing.T) { TestingT(t) } |
| 11 | + |
| 12 | +type CommonSuite struct{} |
| 13 | + |
| 14 | +var _ = Suite(&CommonSuite{}) |
| 15 | + |
| 16 | +func (s *CommonSuite) TestIsRepoNotFoundErrorForUnknowSource(c *C) { |
| 17 | + msg := "unknown system is complaining of something very sad :(" |
| 18 | + |
| 19 | + isRepoNotFound := isRepoNotFoundError(msg) |
| 20 | + |
| 21 | + c.Assert(isRepoNotFound, Equals, false) |
| 22 | +} |
| 23 | + |
| 24 | +func (s *CommonSuite) TestIsRepoNotFoundErrorForGithub(c *C) { |
| 25 | + msg := fmt.Sprintf("%s : some error stuf", githubRepoNotFoundErr) |
| 26 | + |
| 27 | + isRepoNotFound := isRepoNotFoundError(msg) |
| 28 | + |
| 29 | + c.Assert(isRepoNotFound, Equals, true) |
| 30 | +} |
| 31 | + |
| 32 | +func (s *CommonSuite) TestIsRepoNotFoundErrorForBitBucket(c *C) { |
| 33 | + msg := fmt.Sprintf("%s : some error stuf", bitbucketRepoNotFoundErr) |
| 34 | + |
| 35 | + isRepoNotFound := isRepoNotFoundError(msg) |
| 36 | + |
| 37 | + c.Assert(isRepoNotFound, Equals, true) |
| 38 | +} |
| 39 | + |
| 40 | +func (s *CommonSuite) TestIsRepoNotFoundErrorForLocal(c *C) { |
| 41 | + msg := fmt.Sprintf("some error stuf : %s", localRepoNotFoundErr) |
| 42 | + |
| 43 | + isRepoNotFound := isRepoNotFoundError(msg) |
| 44 | + |
| 45 | + c.Assert(isRepoNotFound, Equals, true) |
| 46 | +} |
| 47 | + |
| 48 | +func (s *CommonSuite) TestIsRepoNotFoundErrorForGitProtocolNotFound(c *C) { |
| 49 | + msg := fmt.Sprintf("%s : some error stuf", gitProtocolNotFoundErr) |
| 50 | + |
| 51 | + isRepoNotFound := isRepoNotFoundError(msg) |
| 52 | + |
| 53 | + c.Assert(isRepoNotFound, Equals, true) |
| 54 | +} |
| 55 | + |
| 56 | +func (s *CommonSuite) TestIsRepoNotFoundErrorForGitProtocolNoSuch(c *C) { |
| 57 | + msg := fmt.Sprintf("%s : some error stuf", gitProtocolNoSuchErr) |
| 58 | + |
| 59 | + isRepoNotFound := isRepoNotFoundError(msg) |
| 60 | + |
| 61 | + c.Assert(isRepoNotFound, Equals, true) |
| 62 | +} |
| 63 | + |
| 64 | +func (s *CommonSuite) TestIsRepoNotFoundErrorForGitProtocolAccessDenied(c *C) { |
| 65 | + msg := fmt.Sprintf("%s : some error stuf", gitProtocolAccessDeniedErr) |
| 66 | + |
| 67 | + isRepoNotFound := isRepoNotFoundError(msg) |
| 68 | + |
| 69 | + c.Assert(isRepoNotFound, Equals, true) |
| 70 | +} |
| 71 | + |
| 72 | +func (s *CommonSuite) TestIsRepoNotFoundErrorForGogsAccessDenied(c *C) { |
| 73 | + msg := fmt.Sprintf("%s : some error stuf", gogsAccessDeniedErr) |
| 74 | + |
| 75 | + isRepoNotFound := isRepoNotFoundError(msg) |
| 76 | + |
| 77 | + c.Assert(isRepoNotFound, Equals, true) |
| 78 | +} |
0 commit comments