Skip to content

Commit 0c7766a

Browse files
Merge pull request #7 from christopherhein/feature/tests-new-domain
Adding tests and using new gopath domain
2 parents fee8dd1 + 812a3b5 commit 0c7766a

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module go.hein.dev/go-version
2+
3+
go 1.12

readme.adoc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ package main
1515
1616
import (
1717
"fmt"
18-
goVersion "github.com/christopherhein/go-version"
18+
goversion "go.hein.dev/go-version"
1919
"github.com/spf13/cobra"
2020
)
2121
@@ -30,7 +30,7 @@ var (
3030
Long: ``,
3131
Run: func(_ *cobra.Command, _ []string) {
3232
var response string
33-
versionOutput := goVersion.New(version, commit, date)
33+
versionOutput := goversion.New(version, commit, date)
3434
3535
if shortened {
3636
response = versionOutput.ToShortened()
@@ -75,6 +75,15 @@ Commit: <SOMEHASH>
7575
Date: <SOMEDATE>
7676
----
7777

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+
7887
== Contributing
7988

8089
If you want to contribute check out

version_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

0 commit comments

Comments
 (0)