Skip to content

Commit

Permalink
Test: Add tests for parse.go
Browse files Browse the repository at this point in the history
  • Loading branch information
mkchoi212 committed May 19, 2018
1 parent 7e45571 commit 93ed8dd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions conflict/parse_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package conflict

import (
"reflect"
"testing"
)

func TestParseGitInfo(t *testing.T) {
for _, test := range tests {
output := []int{}
for _, line := range test.diffCheck {
_, lineNum, ok := parseGitMarkerInfo(line)
if ok != nil {
continue
}
output = append(output, lineNum)
}

if !(reflect.DeepEqual(output, test.markers)) && test.parsable {
t.Errorf("parseGitInfo failed: got %v, want %v", output, test.markers)
}
}
}

func TestParseConflictsIn(t *testing.T) {
for _, test := range tests {
f := File{AbsolutePath: test.path}
if err := f.Read(); err != nil && test.highlightable {
t.Error("ParseConflicts/Read failed")
}

_, err := parseConflictsIn(f, test.markers)
if err != nil && test.parsable {
t.Errorf("parseConflicts failed: %s", err.Error())
}
}
}

0 comments on commit 93ed8dd

Please sign in to comment.