go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/services/upstart_test.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package services
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  	"github.com/stretchr/testify/require"
    11  	"go.mondoo.com/cnquery/providers-sdk/v1/inventory"
    12  	"go.mondoo.com/cnquery/providers/os/connection/mock"
    13  )
    14  
    15  func TestParseUpstartServicesRunning(t *testing.T) {
    16  	mock, err := mock.New("./testdata/ubuntu1404.toml", &inventory.Asset{
    17  		Platform: &inventory.Platform{
    18  			Name:   "ubuntu",
    19  			Family: []string{"linux", "ubuntu"},
    20  		},
    21  	})
    22  	require.NoError(t, err)
    23  
    24  	upstart := UpstartServiceManager{SysVServiceManager{conn: mock}}
    25  
    26  	// iterate over services and check if they are running
    27  	services, err := upstart.List()
    28  	require.NoError(t, err)
    29  	assert.Equal(t, 9, len(services), "detected the right amount of services")
    30  }