2022-10-17 07:24:07 +00:00
|
|
|
package hubtest
|
2022-03-02 10:30:04 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-11-07 13:02:02 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2022-03-02 10:30:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestCheckPathNotContained(t *testing.T) {
|
2023-11-07 13:02:02 +00:00
|
|
|
require.NoError(t, checkPathNotContained("/foo", "/bar"))
|
|
|
|
require.NoError(t, checkPathNotContained("/foo/bar", "/foo"))
|
|
|
|
require.NoError(t, checkPathNotContained("/foo/bar", "/"))
|
|
|
|
require.NoError(t, checkPathNotContained("/path/to/somewhere", "/path/to/somewhere-else"))
|
|
|
|
require.NoError(t, checkPathNotContained("~/.local/path/to/somewhere", "~/.local/path/to/somewhere-else"))
|
|
|
|
require.Error(t, checkPathNotContained("/foo", "/foo/bar"))
|
|
|
|
require.Error(t, checkPathNotContained("/", "/foo"))
|
|
|
|
require.Error(t, checkPathNotContained("/", "/foo/bar/baz"))
|
2022-03-02 10:30:04 +00:00
|
|
|
}
|