diff options
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/hugo_info.go | 6 | ||||
-rw-r--r-- | hugolib/hugo_info_test.go | 33 |
2 files changed, 36 insertions, 3 deletions
diff --git a/hugolib/hugo_info.go b/hugolib/hugo_info.go index 1e0c192e5..303231edb 100644 --- a/hugolib/hugo_info.go +++ b/hugolib/hugo_info.go @@ -1,4 +1,4 @@ -// Copyright 2015 The Hugo Authors. All rights reserved. +// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ var hugoInfo *HugoInfo // HugoInfo contains information about the current Hugo environment type HugoInfo struct { - Version string + Version helpers.HugoVersionString Generator template.HTML CommitHash string BuildDate string @@ -41,7 +41,7 @@ type HugoInfo struct { func init() { hugoInfo = &HugoInfo{ - Version: helpers.CurrentHugoVersion.String(), + Version: helpers.CurrentHugoVersion.Version(), CommitHash: CommitHash, BuildDate: BuildDate, Generator: template.HTML(fmt.Sprintf(`<meta name="generator" content="Hugo %s" />`, helpers.CurrentHugoVersion.String())), diff --git a/hugolib/hugo_info_test.go b/hugolib/hugo_info_test.go new file mode 100644 index 000000000..0a34330ac --- /dev/null +++ b/hugolib/hugo_info_test.go @@ -0,0 +1,33 @@ +// Copyright 2018 The Hugo Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package hugolib + +import ( + "fmt" + "testing" + + "github.com/gohugoio/hugo/helpers" + "github.com/stretchr/testify/require" +) + +func TestHugoInfo(t *testing.T) { + assert := require.New(t) + + assert.Equal(helpers.CurrentHugoVersion.Version(), hugoInfo.Version) + assert.IsType(helpers.HugoVersionString(""), hugoInfo.Version) + assert.Equal(CommitHash, hugoInfo.CommitHash) + assert.Equal(BuildDate, hugoInfo.BuildDate) + assert.Contains(hugoInfo.Generator, fmt.Sprintf("Hugo %s", hugoInfo.Version)) + +} |