go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/mount_test.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package resources_test 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestResource_Mount(t *testing.T) { 13 t.Run("list mount points", func(t *testing.T) { 14 res := x.TestQuery(t, "mount.list") 15 assert.NotEmpty(t, res) 16 }) 17 18 t.Run("check first mount entry", func(t *testing.T) { 19 res := x.TestQuery(t, "mount.list[0].device") 20 assert.NotEmpty(t, res) 21 assert.Empty(t, res[0].Result().Error) 22 assert.Equal(t, "proc", res[0].Data.Value) 23 }) 24 25 t.Run("search for mountpoint on root /", func(t *testing.T) { 26 res := x.TestQuery(t, "mount.where(path == \"/\").list[0].device") 27 assert.NotEmpty(t, res) 28 assert.Empty(t, res[0].Result().Error) 29 assert.Equal(t, "/dev/sda1", res[0].Data.Value) 30 }) 31 32 t.Run("check mount point resource", func(t *testing.T) { 33 res := x.TestQuery(t, "mount.point(\"/dev\").mounted") 34 assert.NotEmpty(t, res) 35 assert.Equal(t, true, res[0].Data.Value) 36 37 res = x.TestQuery(t, "mount.point(\"/notthere\").mounted") 38 assert.NotEmpty(t, res) 39 assert.Equal(t, false, res[0].Data.Value) 40 }) 41 }