chore(tun): fix unit test for unprivileged user

This commit is contained in:
Quentin McGaw
2024-03-25 18:31:45 +00:00
parent 3e79509c97
commit 23b0320cfb

View File

@@ -4,6 +4,7 @@ package tun
import ( import (
"os" "os"
"strings"
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -50,6 +51,10 @@ func Test_Tun(t *testing.T) {
// Create TUN device success // Create TUN device success
err = tun.Create(path) err = tun.Create(path)
if err != nil && strings.HasSuffix(err.Error(), "operation not permitted") {
t.Skip("You do not have root privileges to create a TUN device, skipping test")
return
}
require.NoError(t, err) require.NoError(t, err)
// Check TUN device success // Check TUN device success