diff --git a/commands/command_track_test.go b/commands/command_track_test.go new file mode 100644 index 00000000..f4f3792a --- /dev/null +++ b/commands/command_track_test.go @@ -0,0 +1,35 @@ +package commands + +import "testing" + +type checker struct { + *testing.T +} + +func TestAbsRelPath(t *testing.T) { + c := &checker{t} + + ae := "/home/test" + re := "test" + a, r := absRelPath("test", "/home") + c.Check(a, ae) + c.Check(r, re) + + ae = "/home/test/some/directory/with/a/file.txt" + re = "some/directory/with/a/file.txt" + a, r = absRelPath("/home/test/some/directory/with/a/file.txt", "/home/test") + c.Check(a, ae) + c.Check(r, re) + + ae = "/home/test/some/directory/with/a/file.txt" + re = "some/directory/with/a/file.txt" + a, r = absRelPath("some/directory/with/a/file.txt", "/home/test") + c.Check(a, ae) + c.Check(r, re) +} + +func (c *checker) Check(g, e string) { + if g != e { + c.Errorf("Expected %s got %s", e, g) + } +}