Skip to content

Commit

Permalink
chore(tun): fix unit test for unprivileged user
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Mar 25, 2024
1 parent 3e79509 commit 23b0320
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/tun/tun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package tun

import (
"os"
"strings"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -50,6 +51,10 @@ func Test_Tun(t *testing.T) {

// Create TUN device success
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)

// Check TUN device success
Expand Down

0 comments on commit 23b0320

Please sign in to comment.