File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change
1
+ module go.hein.dev/go-version
2
+
3
+ go 1.12
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ package main
15
15
16
16
import (
17
17
"fmt"
18
- goVersion "github.com/christopherhein /go-version"
18
+ goversion "go.hein.dev /go-version"
19
19
"github.com/spf13/cobra"
20
20
)
21
21
30
30
Long: ``,
31
31
Run: func(_ *cobra.Command, _ []string) {
32
32
var response string
33
- versionOutput := goVersion .New(version, commit, date)
33
+ versionOutput := goversion .New(version, commit, date)
34
34
35
35
if shortened {
36
36
response = versionOutput.ToShortened()
@@ -75,6 +75,15 @@ Commit: <SOMEHASH>
75
75
Date: <SOMEDATE>
76
76
----
77
77
78
+ == Testing
79
+
80
+ To run the test suite all you need to do is run.
81
+
82
+ [source,shell]
83
+ ----
84
+ go test -v ./...
85
+ ----
86
+
78
87
== Contributing
79
88
80
89
If you want to contribute check out
Original file line number Diff line number Diff line change
1
+ package version
2
+
3
+ import "testing"
4
+
5
+ func TestToJSON (t * testing.T ) {
6
+ v := New ("dev" , "fee8dd1f7c24da23508e26347694be0acce5631b" , "Fri Jun 21 10:50:15 PDT 2019" )
7
+ json := v .ToJSON ()
8
+
9
+ expected := "{\" Version\" :\" dev\" ,\" Commit\" :\" fee8dd1f7c24da23508e26347694be0acce5631b\" ,\" Date\" :\" Fri Jun 21 10:50:15 PDT 2019\" }\n "
10
+ if json != expected {
11
+ t .Errorf ("Expected json %s to equal %s" , json , expected )
12
+ }
13
+ }
14
+
15
+ func TestToShortened (t * testing.T ) {
16
+ v := New ("dev" , "fee8dd1f7c24da23508e26347694be0acce5631b" , "Fri Jun 21 10:50:15 PDT 2019" )
17
+ short := v .ToShortened ()
18
+
19
+ expected := `Version: dev
20
+ Commit: fee8dd1f7c24da23508e26347694be0acce5631b
21
+ Date: Fri Jun 21 10:50:15 PDT 2019
22
+ `
23
+
24
+ if short != expected {
25
+ t .Errorf ("Expected shortened %s to equal %s" , short , expected )
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments