Shaman: skip certain tests if the platform cannot do symlinking reliably

Windows 10 Home ("Core") only allows symlinking when running as admin,
which is not recommended for Flamenco Manager. Instead of failing unit
tests on this system, simply skip them. This reduces noise when developing
on this platform (i.e. my personal laptop) a lot.
This commit is contained in:
Sybren A. Stüvel 2023-10-15 14:26:32 +02:00
parent 12bc182857
commit d60af809be
4 changed files with 30 additions and 0 deletions

@ -9,9 +9,12 @@ import (
"github.com/stretchr/testify/assert"
"projects.blender.org/studio/flamenco/pkg/api"
"projects.blender.org/studio/flamenco/pkg/shaman/filestore"
"projects.blender.org/studio/flamenco/pkg/shaman/testsupport"
)
func TestCheckout(t *testing.T) {
testsupport.SkipTestIfUnableToSymlink(t)
manager, cleanup := createTestManager()
defer cleanup()
ctx := context.Background()

@ -36,6 +36,7 @@ import (
"projects.blender.org/studio/flamenco/pkg/api"
"projects.blender.org/studio/flamenco/pkg/shaman/config"
"projects.blender.org/studio/flamenco/pkg/shaman/filestore"
"projects.blender.org/studio/flamenco/pkg/shaman/testsupport"
)
func createTestManager() (*Manager, func()) {
@ -46,6 +47,8 @@ func createTestManager() (*Manager, func()) {
}
func TestSymlinkToCheckout(t *testing.T) {
testsupport.SkipTestIfUnableToSymlink(t)
manager, cleanup := createTestManager()
defer cleanup()
@ -101,6 +104,8 @@ func TestPrepareCheckout(t *testing.T) {
}
func TestEraseCheckout(t *testing.T) {
testsupport.SkipTestIfUnableToSymlink(t)
manager, cleanup := createTestManager()
defer cleanup()
ctx := context.Background()

@ -36,6 +36,7 @@ import (
"projects.blender.org/studio/flamenco/pkg/shaman/config"
"projects.blender.org/studio/flamenco/pkg/shaman/filestore"
"projects.blender.org/studio/flamenco/pkg/shaman/jwtauth"
"projects.blender.org/studio/flamenco/pkg/shaman/testsupport"
)
func createTestShaman() (*Server, func()) {
@ -116,6 +117,8 @@ func TestGCFindOldFiles(t *testing.T) {
// Test of the lower-level functions of the garbage collector.
func TestGCComponents(t *testing.T) {
testsupport.SkipTestIfUnableToSymlink(t)
server, cleanup := createTestShaman()
defer cleanup()
@ -200,6 +203,8 @@ func TestGCComponents(t *testing.T) {
// Test of the high-level GCStorage() function.
func TestGarbageCollect(t *testing.T) {
testsupport.SkipTestIfUnableToSymlink(t)
server, cleanup := createTestShaman()
defer cleanup()

@ -0,0 +1,17 @@
package testsupport
import (
"testing"
"projects.blender.org/studio/flamenco/pkg/sysinfo"
)
func SkipTestIfUnableToSymlink(t *testing.T) {
can, err := sysinfo.CanSymlink()
switch {
case err != nil:
t.Fatalf("error checking platform symlinking capabilities: %v", err)
case !can:
t.Skip("symlinking not possible on current platform")
}
}