Added some basic unit tests for some of the utility functions
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
cf854a91f0
commit
6d1a24cefb
@ -6,6 +6,11 @@ pipeline:
|
|||||||
- GOOS=linux GOARCH=amd64 go build -o "dist/adept-linux-amd64-${CI_COMMIT_TAG}"
|
- GOOS=linux GOARCH=amd64 go build -o "dist/adept-linux-amd64-${CI_COMMIT_TAG}"
|
||||||
- GOOS=windows GOARCH=amd64 go build -o "dist/adept-windows-amd64-${CI_COMMIT_TAG}.exe"
|
- GOOS=windows GOARCH=amd64 go build -o "dist/adept-windows-amd64-${CI_COMMIT_TAG}.exe"
|
||||||
|
|
||||||
|
test:
|
||||||
|
image: golang:1.16
|
||||||
|
commands:
|
||||||
|
- go test -v ./...
|
||||||
|
|
||||||
gitea_release:
|
gitea_release:
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
settings:
|
settings:
|
||||||
|
17
Makefile
Normal file
17
Makefile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
BINARY_NAME=adept
|
||||||
|
|
||||||
|
all: build test
|
||||||
|
|
||||||
|
build:
|
||||||
|
go build -o ${BINARY_NAME} adept.go
|
||||||
|
|
||||||
|
test:
|
||||||
|
go test -v ./...
|
||||||
|
|
||||||
|
run:
|
||||||
|
go build -o ${BINARY_NAME} adept.go
|
||||||
|
./${BINARY_NAME}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
go clean
|
||||||
|
rm ${BINARY_NAME}
|
19
util/env_test.go
Normal file
19
util/env_test.go
Normal 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
11
util/file_test.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user