Added some basic unit tests for some of the utility functions
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2022-09-01 14:25:02 -04:00
parent cf854a91f0
commit 6d1a24cefb
4 changed files with 52 additions and 0 deletions

19
util/env_test.go Normal file
View File

@ -0,0 +1,19 @@
package util
import "testing"
func TestResolveTilde(t *testing.T) {
resolvedPath := ResolveTilde("~")
if resolvedPath == "~" {
t.Logf("ResolveTilde returned '%s'; it should have expanded to an absolute path.", resolvedPath)
}
}
func TestResolveTildePath(t *testing.T) {
resolvedPath := ResolveTilde("~/test")
if resolvedPath == "~/test" {
t.Logf("ResolveTilde returned '%s'; it should have expanded to an absolute path.", resolvedPath)
}
}

11
util/file_test.go Normal file
View File

@ -0,0 +1,11 @@
package util
import "testing"
func TestFilenameWithoutExtension(t *testing.T) {
filename := FilenameWithoutExtension("testfile.txt")
if filename != "testfile" {
t.Logf("FilenameWithoutExtension returned '%s'; it should be 'testfile'.", filename)
}
}