1
0
Fork 0
mirror of https://github.com/vbatts/git-validation.git synced 2024-12-28 00:16:29 +00:00
git-validation/git/commits_test.go
Vincent Batts 3ec88517cc git: restructured commit entries
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-05 15:28:38 -04:00

55 lines
880 B
Go

package git
import (
"encoding/json"
"io/ioutil"
"testing"
)
func TestCommitEntry(t *testing.T) {
c, err := HeadCommit()
if err != nil {
t.Fatal(err)
}
cr, err := Commits(c)
if err != nil {
t.Fatal(err)
}
for _, c := range cr {
for _, cV := range FieldNames {
found := false
for k := range c {
if k == cV {
found = true
}
}
if !found {
t.Errorf("failed to find field names: %q", c)
}
}
}
}
func TestMarshal(t *testing.T) {
buf, err := ioutil.ReadFile("testdata/commits.json")
if err != nil {
t.Fatal(err)
}
cr := []CommitEntry{}
if err := json.Unmarshal(buf, &cr); err != nil {
t.Error(err)
}
for _, c := range cr {
for _, cV := range FieldNames {
found := false
for k := range c {
if k == cV {
found = true
}
}
if !found {
t.Errorf("failed to find field names: %q", c)
}
}
}
}