github.com/crowdsecurity/crowdsec@v1.6.1/pkg/hubtest/utils_test.go (about)

     1  package hubtest
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  )
     8  
     9  func TestCheckPathNotContained(t *testing.T) {
    10  	require.NoError(t, checkPathNotContained("/foo", "/bar"))
    11  	require.NoError(t, checkPathNotContained("/foo/bar", "/foo"))
    12  	require.NoError(t, checkPathNotContained("/foo/bar", "/"))
    13  	require.NoError(t, checkPathNotContained("/path/to/somewhere", "/path/to/somewhere-else"))
    14  	require.NoError(t, checkPathNotContained("~/.local/path/to/somewhere", "~/.local/path/to/somewhere-else"))
    15  	require.Error(t, checkPathNotContained("/foo", "/foo/bar"))
    16  	require.Error(t, checkPathNotContained("/", "/foo"))
    17  	require.Error(t, checkPathNotContained("/", "/foo/bar/baz"))
    18  }