pulumi/pkg/engine/update_test.go
2020-01-30 13:31:41 -08:00

49 lines
1.2 KiB
Go

package engine
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestAbbreviateFilePath(t *testing.T) {
tests := []struct {
path string
expected string
}{
{
path: "/Users/username/test-policy",
expected: "/Users/username/test-policy",
},
{
path: "./..//test-policy",
expected: "../test-policy",
},
{
path: `/Users/username/averylongpath/one/two/three/four/` +
`five/six/seven/eight/nine/ten/eleven/twelve/test-policy`,
expected: "/Users/.../twelve/test-policy",
},
{
path: `nonrootdir/username/averylongpath/one/two/three/four/` +
`five/six/seven/eight/nine/ten/eleven/twelve/test-policy`,
expected: "nonrootdir/username/.../twelve/test-policy",
},
{
path: `C:/Documents and Settings/username/My Documents/averylongpath/` +
`one/two/three/four/five/six/seven/eight/test-policy`,
expected: "C:/Documents and Settings/.../eight/test-policy",
},
{
path: `C:\Documents and Settings\username\My Documents\averylongpath\` +
`one\two\three\four\five\six\seven\eight\test-policy`,
expected: `C:\Documents and Settings\...\eight\test-policy`,
},
}
for _, tt := range tests {
actual := abbreviateFilePath(tt.path)
assert.Equal(t, tt.expected, actual)
}
}