go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/reboot/debian_test.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package reboot 5 6 import ( 7 "path/filepath" 8 "testing" 9 10 "github.com/stretchr/testify/assert" 11 "github.com/stretchr/testify/require" 12 "go.mondoo.com/cnquery/providers-sdk/v1/inventory" 13 "go.mondoo.com/cnquery/providers/os/connection/mock" 14 ) 15 16 func TestRebootLinux(t *testing.T) { 17 filepath, _ := filepath.Abs("./testdata/ubuntu_reboot.toml") 18 provider, err := mock.New(filepath, &inventory.Asset{ 19 Platform: &inventory.Platform{ 20 Name: "ubuntu", 21 Family: []string{"linux", "debian", "ubuntu"}, 22 }, 23 }) 24 require.NoError(t, err) 25 26 lb := DebianReboot{conn: provider} 27 required, err := lb.RebootPending() 28 require.NoError(t, err) 29 assert.Equal(t, true, required) 30 } 31 32 func TestNoRebootLinux(t *testing.T) { 33 filepath, _ := filepath.Abs("./testdata/ubuntu_noreboot.toml") 34 provider, err := mock.New(filepath, &inventory.Asset{ 35 Platform: &inventory.Platform{ 36 Name: "ubuntu", 37 Family: []string{"linux", "debian", "ubuntu"}, 38 }, 39 }) 40 require.NoError(t, err) 41 42 lb := DebianReboot{conn: provider} 43 required, err := lb.RebootPending() 44 require.NoError(t, err) 45 assert.Equal(t, false, required) 46 }