Răsfoiți Sursa

chore: add more tests (#3259)

Kevin Wan 1 an în urmă
părinte
comite
701bb31ed2
2 a modificat fișierele cu 14 adăugiri și 1 ștergeri
  1. 2 1
      core/stat/internal/cgroup_linux.go
  2. 12 0
      core/stat/internal/cgroup_linux_test.go

+ 2 - 1
core/stat/internal/cgroup_linux.go

@@ -3,6 +3,7 @@ package internal
 import (
 import (
 	"bufio"
 	"bufio"
 	"fmt"
 	"fmt"
+	"math"
 	"os"
 	"os"
 	"path"
 	"path"
 	"strconv"
 	"strconv"
@@ -280,7 +281,7 @@ func runningInUserNS() bool {
 
 
 		// We assume we are in the initial user namespace if we have a full
 		// We assume we are in the initial user namespace if we have a full
 		// range - 4294967295 uids starting at uid 0.
 		// range - 4294967295 uids starting at uid 0.
-		if a == 0 && b == 0 && c == 4294967295 {
+		if a == 0 && b == 0 && c == math.MaxUint32 {
 			return
 			return
 		}
 		}
 		inUserNS = true
 		inUserNS = true

+ 12 - 0
core/stat/internal/cgroup_linux_test.go

@@ -0,0 +1,12 @@
+package internal
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestRunningInUserNS(t *testing.T) {
+	// should be false in docker
+	assert.False(t, runningInUserNS())
+}