Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Mar 5, 2024
1 parent ee0903f commit 93b0192
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions providers-sdk/v1/plugin/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v10/utils/syncx"
)

Expand Down Expand Up @@ -59,7 +60,7 @@ func TestAddRuntime(t *testing.T) {
addRuntimes := func() {
defer wg.Done()
for i := 0; i < 50; i++ {
_, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
_, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
return &Runtime{}, nil
})
require.NoError(t, err)
Expand All @@ -82,7 +83,7 @@ func TestAddRuntime(t *testing.T) {
func TestAddRuntime_ParentNotExist(t *testing.T) {
s := NewService()
parentId := uint32(10)
_, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
_, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
c := newTestConnection(connId)
c.parentId = parentId
return &Runtime{
Expand All @@ -96,7 +97,7 @@ func TestAddRuntime_ParentNotExist(t *testing.T) {
func TestAddRuntime_Parent(t *testing.T) {
s := NewService()

parent, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
parent, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
resMap := &syncx.Map[Resource]{}
resMap.Set("test.resource", &TestResource{})

Expand All @@ -108,7 +109,7 @@ func TestAddRuntime_Parent(t *testing.T) {
require.NoError(t, err)

parentId := parent.Connection.ID()
child, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
child, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
c := newTestConnection(connId)
c.parentId = parentId
return &Runtime{
Expand All @@ -128,7 +129,7 @@ func TestAddRuntime_Parent(t *testing.T) {
func TestGetRuntime(t *testing.T) {
s := NewService()

runtime, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
runtime, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
return &Runtime{
Connection: newTestConnection(connId),
}, nil
Expand All @@ -137,7 +138,7 @@ func TestGetRuntime(t *testing.T) {

// Add some more runtimes
for i := 0; i < 5; i++ {
_, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
_, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
return &Runtime{
Connection: newTestConnection(connId),
}, nil
Expand All @@ -154,7 +155,7 @@ func TestGetRuntime(t *testing.T) {
func TestGetRuntime_DoesNotExist(t *testing.T) {
s := NewService()

_, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
_, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
return &Runtime{
Connection: newTestConnection(connId),
}, nil
Expand All @@ -169,7 +170,7 @@ func TestGetRuntime_DoesNotExist(t *testing.T) {
func TestDisconnect(t *testing.T) {
s := NewService()

runtime, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
runtime, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
return &Runtime{
Connection: newTestConnection(connId),
}, nil
Expand All @@ -186,7 +187,7 @@ func TestDisconnect(t *testing.T) {
func TestDisconnect_Closer(t *testing.T) {
s := NewService()

runtime, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
runtime, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
return &Runtime{
Connection: newTestConnectionWithClose(connId),
}, nil
Expand All @@ -208,7 +209,7 @@ func TestShutdown(t *testing.T) {

// Add some more runtimes
for i := 0; i < 50; i++ {
_, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
_, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
return &Runtime{
Connection: newTestConnection(connId),
}, nil
Expand All @@ -228,7 +229,7 @@ func TestShutdown_Closer(t *testing.T) {
// Add some more runtimes
runtimes := []*Runtime{}
for i := 0; i < 50; i++ {
runtime, err := s.AddRuntime(func(connId uint32) (*Runtime, error) {
runtime, err := s.AddRuntime(&inventory.Config{}, func(connId uint32) (*Runtime, error) {
return &Runtime{
Connection: newTestConnectionWithClose(connId),
}, nil
Expand Down

0 comments on commit 93b0192

Please sign in to comment.