Files
photoview/api/test_utils/env_test.go
Googol Lee f1b523a27e Include a group of small but real media files for testing. (#1131)
* Move scanner/test_data/* to a stand-alone directory.

* Include real medias.

* Rename testdata to test_data

* Rename test_data/scanner -> test_data/library

* Clean tests to avoid depneding env.

* Rename: scanner/test_data -> scanner/test_media

* Rename: test_data/bin -> test_data/mock_bin

* Fix paths in tests.
2024-11-23 09:02:11 +01:00

27 lines
606 B
Go

package test_utils
import (
"os"
"strings"
"testing"
)
func TestPathFromAPIRoot(t *testing.T) {
if got, want := PathFromAPIRoot("./server.go"), "/api/server.go"; !strings.HasSuffix(got, want) {
t.Fatalf(`PathFromAPIRoot("./server.go") = %q, want a suffix: %q`, got, want)
}
}
func TestSetPathWithCurrent(t *testing.T) {
pathDone := SetEnv("PATH", "")
defer pathDone()
testDone := SetPathWithCurrent("./test")
defer testDone()
path := os.Getenv("PATH")
if got, want := path, "api/test_utils/test"; !strings.HasSuffix(got, want) {
t.Errorf("path = %q, want a suffix: %q", got, want)
}
}