1
1
mirror of https://github.com/cooperspencer/gickup synced 2024-11-08 12:09:18 +01:00
gickup/main_test.go
Tom Moulard 646b792ac1
chore: add linting (#101)
* chore: adding makefile

* chore: adding lint

* chore: update package name

* lint: run with fix

* chore: update main.go

* chore: update main_test.go

* chore: update types.go

* chore: update logger.go

* chore: update types_test.go

* chore: update prometheus.go

* chore: update local.go

* chore: update gitlab.go

* chore: update gogs.go

* chore: update bitbucket.go

* chore: update gitea.go

* chore: update github.go

* chore: update main*.go

* chore: go mod tidy

* chore: update action to have a correct working-directory
2022-03-20 11:25:11 +01:00

37 lines
765 B
Go

package main
import (
"strings"
"testing"
)
func TestTildeReplacement_NoAction(t *testing.T) {
t.Parallel()
if path := "/boop"; substituteHomeForTildeInPath(path) != path {
t.Error("Altered path when no alteration was expected")
}
}
func TestTildeReplacement_TildeOnly(t *testing.T) {
t.Parallel()
if path := "~"; substituteHomeForTildeInPath(path) == path {
t.Error("Path unaltered when alteration was expected")
}
}
func TestTildeReplacement_TildeDir(t *testing.T) {
t.Parallel()
path := "~/boop"
actual := substituteHomeForTildeInPath(path)
if strings.HasPrefix(actual, "~") {
t.Error("Altered path still contains ~")
}
if !strings.HasSuffix(actual, "boop") {
t.Error("Altered path does not end with directory to be retained")
}
}