-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests and using new gopath domain
Signed-off-by: Christopher Hein <me@chrishein.com>
- Loading branch information
1 parent
fee8dd1
commit 812a3b5
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module go.hein.dev/go-version | ||
|
||
go 1.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package version | ||
|
||
import "testing" | ||
|
||
func TestToJSON(t *testing.T) { | ||
v := New("dev", "fee8dd1f7c24da23508e26347694be0acce5631b", "Fri Jun 21 10:50:15 PDT 2019") | ||
json := v.ToJSON() | ||
|
||
expected := "{\"Version\":\"dev\",\"Commit\":\"fee8dd1f7c24da23508e26347694be0acce5631b\",\"Date\":\"Fri Jun 21 10:50:15 PDT 2019\"}\n" | ||
if json != expected { | ||
t.Errorf("Expected json %s to equal %s", json, expected) | ||
} | ||
} | ||
|
||
func TestToShortened(t *testing.T) { | ||
v := New("dev", "fee8dd1f7c24da23508e26347694be0acce5631b", "Fri Jun 21 10:50:15 PDT 2019") | ||
short := v.ToShortened() | ||
|
||
expected := `Version: dev | ||
Commit: fee8dd1f7c24da23508e26347694be0acce5631b | ||
Date: Fri Jun 21 10:50:15 PDT 2019 | ||
` | ||
|
||
if short != expected { | ||
t.Errorf("Expected shortened %s to equal %s", short, expected) | ||
} | ||
} |