gotest.tools/gotestsum@v1.11.0/testjson/pkgpathprefix_test.go (about) 1 package testjson 2 3 import ( 4 "testing" 5 6 "gotest.tools/v3/assert" 7 "gotest.tools/v3/skip" 8 ) 9 10 func TestRelativePackagePath(t *testing.T) { 11 prefix := "gotest.tools/gotestsum/testjson" 12 patchPkgPathPrefix(t, prefix) 13 relPath := RelativePackagePath(prefix + "/extra/relpath") 14 assert.Equal(t, relPath, "extra/relpath") 15 16 relPath = RelativePackagePath(prefix) 17 assert.Equal(t, relPath, ".") 18 } 19 20 func TestGetPkgPathPrefix(t *testing.T) { 21 t.Run("with go path", func(t *testing.T) { 22 skip.If(t, isGoModuleEnabled()) 23 assert.Equal(t, getPkgPathPrefix(), "gotest.tools/gotestsum/testjson") 24 }) 25 t.Run("with go modules", func(t *testing.T) { 26 skip.If(t, !isGoModuleEnabled()) 27 assert.Equal(t, getPkgPathPrefix(), "gotest.tools/gotestsum") 28 }) 29 }