summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike JS. Choi <mkchoi212@icloud.com>2018-01-01 22:00:19 -0600
committerMike JS. Choi <mkchoi212@icloud.com>2018-01-01 22:00:19 -0600
commitde61c399a2f4efd714a01be3aa2dc9a4d708ec15 (patch)
tree2d541aab03902937d44615fe3e0741577dd18d8f
parent46dd5b9f3ab1183fdf4d08cf0d5ac986f9c89bea (diff)
Add basic tests for conflict struct
-rw-r--r--conflict/conflict.go2
-rw-r--r--conflict/conflict_test.go36
2 files changed, 37 insertions, 1 deletions
diff --git a/conflict/conflict.go b/conflict/conflict.go
index f254b18..f820640 100644
--- a/conflict/conflict.go
+++ b/conflict/conflict.go
@@ -44,7 +44,7 @@ func (e *ErrNoConflict) Error() string {
}
func (c *Conflict) Equal(c2 *Conflict) bool {
- return c.FileName == c2.FileName && c.Start == c2.Start
+ return c.AbsolutePath == c2.AbsolutePath && c.Start == c2.Start
}
func (c *Conflict) ToggleDiff() {
diff --git a/conflict/conflict_test.go b/conflict/conflict_test.go
new file mode 100644
index 0000000..6c47813
--- /dev/null
+++ b/conflict/conflict_test.go
@@ -0,0 +1,36 @@
+package conflict
+
+import (
+ "testing"
+)
+
+func TestEqual(t *testing.T) {
+ c1, c2, c3 := Conflict{}, Conflict{}, Conflict{}
+
+ c1.FileName, c2.FileName, c3.FileName = "foobar", "foobar", "foobar"
+ c1.Start, c2.Start, c3.Start = 45, 45, 45
+
+ c1.AbsolutePath, c2.AbsolutePath = "/path/foobar", "/path/foobar"
+ c3.AbsolutePath = "/other/path/foobar"
+
+ if c1.Equal(&c2) != true {
+ t.Errorf("%v and %v should be equal", c1, c2)
+ }
+
+ if c1.Equal(&c3) != false {
+ t.Errorf("%v and %v should NOT be equal", c1, c3)
+ }
+}
+
+func TestToggleDiff(t *testing.T) {
+ c1 := Conflict{}
+ c1.ToggleDiff()
+ if c1.DisplayDiff != true {
+ t.Errorf("%v should be toggled ON", c1)
+ }
+
+ c1.ToggleDiff()
+ if c1.DisplayDiff != false {
+ t.Errorf("%v should be toggled OFF", c1)
+ }
+}