Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthakumaran committed Oct 20, 2024
1 parent 3d610c2 commit 010a078
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions internal/utils/utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package utils

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestBuildSubPath(t *testing.T) {
path, err := BuildSubPath("/usr/home/john/paisa", "main.ledger")
assert.Nil(t, err)
assert.Equal(t, "/usr/home/john/paisa/main.ledger", path)

path, err = BuildSubPath("/usr/home/john/paisa", "subfolder/main.ledger")
assert.Nil(t, err)
assert.Equal(t, "/usr/home/john/paisa/subfolder/main.ledger", path)

path, err = BuildSubPath("/usr/home/john/paisa", "../../../subfolder/travel.ledger")
assert.Error(t, err)

path, err = BuildSubPath("/usr/home/john/paisa", "..")
assert.Error(t, err)

path, err = BuildSubPath("/usr/home/john/paisa", "./..")
assert.Error(t, err)

path, err = BuildSubPath("/usr/home/john/paisa", "./../test.ledger")
assert.Error(t, err)
}

0 comments on commit 010a078

Please sign in to comment.