Skip to content

Commit

Permalink
fix more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Feb 12, 2024
1 parent 4b63fbf commit 537366e
Show file tree
Hide file tree
Showing 36 changed files with 101 additions and 71 deletions.
7 changes: 4 additions & 3 deletions providers/os/connection/local/statutil/stat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ 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/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/connection/shared"
)

func TestLinuxStatCmd(t *testing.T) {
filepath, _ := filepath.Abs("./testdata/linux.toml")
p, err := mock.New(0, filepath, nil)
p, err := mock.New(0, filepath, &inventory.Asset{})
require.NoError(t, err)

statHelper := New(p)
Expand All @@ -45,7 +46,7 @@ func TestLinuxStatCmd(t *testing.T) {

func TestOpenbsdStatCmd(t *testing.T) {
filepath, _ := filepath.Abs("./testdata/openbsd.toml")
p, err := mock.New(0, filepath, nil)
p, err := mock.New(0, filepath, &inventory.Asset{})
require.NoError(t, err)

statHelper := New(p)
Expand All @@ -65,7 +66,7 @@ func TestOpenbsdStatCmd(t *testing.T) {

func TestAixStatCmd(t *testing.T) {
filepath, _ := filepath.Abs("./testdata/aix.toml")
p, err := mock.New(0, filepath, nil)
p, err := mock.New(0, filepath, &inventory.Asset{})
require.NoError(t, err)

statHelper := New(p)
Expand Down
2 changes: 1 addition & 1 deletion providers/os/connection/ssh/cat/cat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

func TestCatFs(t *testing.T) {
filepath, _ := filepath.Abs("./testdata/cat.toml")
p, err := mock.New(0, filepath, nil)
p, err := mock.New(0, filepath, &inventory.Asset{})
require.NoError(t, err)

flags := map[string]*llx.Primitive{
Expand Down
5 changes: 3 additions & 2 deletions providers/os/connection/vagrant/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ 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/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/connection/vagrant"
)

func TestVagrantSshConfigParsing(t *testing.T) {
mock, err := mock.New(0, "./testdata/vagrant.toml", nil)
mock, err := mock.New(0, "./testdata/vagrant.toml", &inventory.Asset{})
require.NoError(t, err)

cmd, err := mock.RunCommand("vagrant ssh-config debian10")
Expand All @@ -30,7 +31,7 @@ func TestVagrantSshConfigParsing(t *testing.T) {
}

func TestVagrantStatusParsing(t *testing.T) {
mock, err := mock.New(0, "./testdata/vagrant.toml", nil)
mock, err := mock.New(0, "./testdata/vagrant.toml", &inventory.Asset{})
require.NoError(t, err)

cmd, err := mock.RunCommand("vagrant status")
Expand Down
3 changes: 2 additions & 1 deletion providers/os/connection/winrm/cat/cat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ 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/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/connection/winrm/cat"
)

func TestCatFs(t *testing.T) {
filepath, _ := filepath.Abs("./testdata/winrm.toml")
p, err := mock.New(0, filepath, nil)
p, err := mock.New(0, filepath, &inventory.Asset{})
require.NoError(t, err)

catfs := cat.New(p)
Expand Down
2 changes: 1 addition & 1 deletion providers/os/detector/detector_platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func detectPlatformFromMock(filepath string) (*inventory.Platform, error) {
mockConn, err := mock.New(0, filepath, nil)
mockConn, err := mock.New(0, filepath, &inventory.Asset{})
if err != nil {
return nil, err
}
Expand Down
9 changes: 5 additions & 4 deletions providers/os/id/aws/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ 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/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/detector"
)

func TestDetectInstance(t *testing.T) {
conn, err := mock.New(0, "./testdata/instance.toml", nil)
conn, err := mock.New(0, "./testdata/instance.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -27,7 +28,7 @@ func TestDetectInstance(t *testing.T) {
}

func TestDetectInstanceArm(t *testing.T) {
conn, err := mock.New(0, "./testdata/instancearm.toml", nil)
conn, err := mock.New(0, "./testdata/instancearm.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -41,7 +42,7 @@ func TestDetectInstanceArm(t *testing.T) {
}

func TestDetectNotInstance(t *testing.T) {
conn, err := mock.New(0, "./testdata/notinstance.toml", nil)
conn, err := mock.New(0, "./testdata/notinstance.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -55,7 +56,7 @@ func TestDetectNotInstance(t *testing.T) {
}

func TestDetectConainer(t *testing.T) {
conn, err := mock.New(0, "./testdata/container.toml", nil)
conn, err := mock.New(0, "./testdata/container.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand Down
9 changes: 5 additions & 4 deletions providers/os/id/awsec2/metadata_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ 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/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/detector"
)

func TestEC2RoleProviderInstanceIdentityUnix(t *testing.T) {
conn, err := mock.New(0, "./testdata/instance-identity_document_linux.toml", nil)
conn, err := mock.New(0, "./testdata/instance-identity_document_linux.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -28,7 +29,7 @@ func TestEC2RoleProviderInstanceIdentityUnix(t *testing.T) {
}

func TestEC2RoleProviderInstanceIdentityUnixNoName(t *testing.T) {
conn, err := mock.New(0, "./testdata/instance-identity_document_linux_no_tags.toml", nil)
conn, err := mock.New(0, "./testdata/instance-identity_document_linux_no_tags.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -43,7 +44,7 @@ func TestEC2RoleProviderInstanceIdentityUnixNoName(t *testing.T) {
}

func TestEC2RoleProviderInstanceIdentityWindows(t *testing.T) {
conn, err := mock.New(0, "./testdata/instance-identity_document_windows.toml", nil)
conn, err := mock.New(0, "./testdata/instance-identity_document_windows.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -58,7 +59,7 @@ func TestEC2RoleProviderInstanceIdentityWindows(t *testing.T) {
}

func TestEC2RoleProviderInstanceIdentityWindowsNoName(t *testing.T) {
conn, err := mock.New(0, "./testdata/instance-identity_document_windows_no_tags.toml", nil)
conn, err := mock.New(0, "./testdata/instance-identity_document_windows_no_tags.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand Down
3 changes: 2 additions & 1 deletion providers/os/id/awsecs/awsecs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/detector"
)
Expand All @@ -22,7 +23,7 @@ func TestParseECSContainerId(t *testing.T) {
}

func TestEC2RoleProviderInstanceIdentityUnix(t *testing.T) {
conn, err := mock.New(0, "./testdata/container-identity.toml", nil)
conn, err := mock.New(0, "./testdata/container-identity.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand Down
5 changes: 3 additions & 2 deletions providers/os/id/azcompute/azcompute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ 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/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/detector"
)

func TestCommandProviderLinux(t *testing.T) {
conn, err := mock.New(0, "./testdata/metadata_linux.toml", nil)
conn, err := mock.New(0, "./testdata/metadata_linux.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -27,7 +28,7 @@ func TestCommandProviderLinux(t *testing.T) {
}

func TestCommandProviderWindows(t *testing.T) {
conn, err := mock.New(0, "./testdata/metadata_windows.toml", nil)
conn, err := mock.New(0, "./testdata/metadata_windows.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand Down
5 changes: 3 additions & 2 deletions providers/os/id/gce/gce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ 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/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/detector"
"go.mondoo.com/cnquery/v10/providers/os/id/gce"
)

func TestCommandProviderLinux(t *testing.T) {
conn, err := mock.New(0, "./testdata/metadata_linux.toml", nil)
conn, err := mock.New(0, "./testdata/metadata_linux.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -29,7 +30,7 @@ func TestCommandProviderLinux(t *testing.T) {
}

func TestCommandProviderWindows(t *testing.T) {
conn, err := mock.New(0, "./testdata/metadata_windows.toml", nil)
conn, err := mock.New(0, "./testdata/metadata_windows.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand Down
7 changes: 4 additions & 3 deletions providers/os/id/gcp/gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ 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/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/detector"
)

func TestDetectLinuxInstance(t *testing.T) {
conn, err := mock.New(0, "./testdata/instance_linux.toml", nil)
conn, err := mock.New(0, "./testdata/instance_linux.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -27,7 +28,7 @@ func TestDetectLinuxInstance(t *testing.T) {
}

func TestDetectWindowsInstance(t *testing.T) {
conn, err := mock.New(0, "./testdata/instance_windows.toml", nil)
conn, err := mock.New(0, "./testdata/instance_windows.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -41,7 +42,7 @@ func TestDetectWindowsInstance(t *testing.T) {
}

func TestNoMatch(t *testing.T) {
conn, err := mock.New(0, "./testdata/aws_instance.toml", nil)
conn, err := mock.New(0, "./testdata/aws_instance.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand Down
11 changes: 6 additions & 5 deletions providers/os/id/hostname/hostname_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ 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/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/detector"
"go.mondoo.com/cnquery/v10/providers/os/id/hostname"
)

func TestHostnameLinuxEtcHostname(t *testing.T) {
conn, err := mock.New(0, "./testdata/hostname_arch.toml", nil)
conn, err := mock.New(0, "./testdata/hostname_arch.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -26,7 +27,7 @@ func TestHostnameLinuxEtcHostname(t *testing.T) {
}

func TestHostnameLinux(t *testing.T) {
conn, err := mock.New(0, "./testdata/hostname_linux.toml", nil)
conn, err := mock.New(0, "./testdata/hostname_linux.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -38,7 +39,7 @@ func TestHostnameLinux(t *testing.T) {
}

func TestHostnameLinuxFqdn(t *testing.T) {
conn, err := mock.New(0, "./testdata/hostname_fqdn.toml", nil)
conn, err := mock.New(0, "./testdata/hostname_fqdn.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -50,7 +51,7 @@ func TestHostnameLinuxFqdn(t *testing.T) {
}

func TestHostnameWindows(t *testing.T) {
conn, err := mock.New(0, "./testdata/hostname_windows.toml", nil)
conn, err := mock.New(0, "./testdata/hostname_windows.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand All @@ -62,7 +63,7 @@ func TestHostnameWindows(t *testing.T) {
}

func TestHostnameMacos(t *testing.T) {
conn, err := mock.New(0, "./testdata/hostname_macos.toml", nil)
conn, err := mock.New(0, "./testdata/hostname_macos.toml", &inventory.Asset{})
require.NoError(t, err)
platform, ok := detector.DetectOS(conn)
require.True(t, ok)
Expand Down
3 changes: 2 additions & 1 deletion providers/os/id/platformid/linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ 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/providers/os/connection/mock"
)

func TestLinuxMachineId(t *testing.T) {
filepath, _ := filepath.Abs("./testdata/linux_test.toml")
provider, err := mock.New(0, filepath, nil)
provider, err := mock.New(0, filepath, &inventory.Asset{})
require.NoError(t, err)

lid := LinuxIdProvider{connection: provider}
Expand Down
3 changes: 2 additions & 1 deletion providers/os/id/platformid/osx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ 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/providers/os/connection/mock"
)

func TestMacOSMachineId(t *testing.T) {
filepath, _ := filepath.Abs("./testdata/osx_test.toml")
provider, err := mock.New(0, filepath, nil)
provider, err := mock.New(0, filepath, &inventory.Asset{})
require.NoError(t, err)

lid := MacOSIdProvider{connection: provider}
Expand Down
3 changes: 2 additions & 1 deletion providers/os/id/platformid/win_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ 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/providers/os/connection/mock"
)

func TestGuidWindows(t *testing.T) {
provider, err := mock.New(0, "./testdata/guid_windows.toml", nil)
provider, err := mock.New(0, "./testdata/guid_windows.toml", &inventory.Asset{})
require.NoError(t, err)

lid := WinIdProvider{connection: provider}
Expand Down
3 changes: 2 additions & 1 deletion providers/os/resources/groups/dscache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v10/providers/os/connection/mock"
"go.mondoo.com/cnquery/v10/providers/os/resources/groups"
)

func TestParseDscacheutilResult(t *testing.T) {
mock, err := mock.New(0, "./testdata/osx.toml", nil)
mock, err := mock.New(0, "./testdata/osx.toml", &inventory.Asset{})
if err != nil {
t.Fatal(err)
}
Expand Down
Loading

0 comments on commit 537366e

Please sign in to comment.