Skip to content

Commit

Permalink
Add basic tests for conflict struct
Browse files Browse the repository at this point in the history
  • Loading branch information
mkchoi212 committed Jan 2, 2018
1 parent 46dd5b9 commit de61c39
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conflict/conflict.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
36 changes: 36 additions & 0 deletions conflict/conflict_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit de61c39

Please sign in to comment.