github.com/olliephillips/hugo@v0.42.2/releaser/git_test.go (about) 1 // Copyright 2017-present The Hugo Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package releaser 15 16 import ( 17 "testing" 18 19 "github.com/stretchr/testify/require" 20 ) 21 22 func TestGitInfos(t *testing.T) { 23 skipIfCI(t) 24 infos, err := getGitInfos("v0.20", "hugo", "", false) 25 26 require.NoError(t, err) 27 require.True(t, len(infos) > 0) 28 29 } 30 31 func TestIssuesRe(t *testing.T) { 32 33 body := ` 34 This is a commit message. 35 36 Updates #123 37 Fix #345 38 closes #543 39 See #456 40 ` 41 42 issues := extractIssues(body) 43 44 require.Len(t, issues, 4) 45 require.Equal(t, 123, issues[0]) 46 require.Equal(t, 543, issues[2]) 47 48 } 49 50 func TestGitVersionTagBefore(t *testing.T) { 51 skipIfCI(t) 52 v1, err := gitVersionTagBefore("v0.18") 53 require.NoError(t, err) 54 require.Equal(t, "v0.17", v1) 55 } 56 57 func TestTagExists(t *testing.T) { 58 skipIfCI(t) 59 b1, err := tagExists("v0.18") 60 require.NoError(t, err) 61 require.True(t, b1) 62 63 b2, err := tagExists("adfagdsfg") 64 require.NoError(t, err) 65 require.False(t, b2) 66 67 } 68 69 func skipIfCI(t *testing.T) { 70 if isCI() { 71 // Travis has an ancient git with no --invert-grep: https://github.com/travis-ci/travis-ci/issues/6328 72 // Also Travis clones very shallowly, making some of the tests above shaky. 73 t.Skip("Skip git test on Linux to make Travis happy.") 74 } 75 }