Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 remove deprecated providers/mock #1851

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions cli/shell/shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
package shell_test

import (
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"go.mondoo.com/cnquery/cli/shell"
"go.mondoo.com/cnquery/providers-sdk/v1/testutils"
"go.mondoo.com/cnquery/providers/mock"
)

func localShell() *shell.Shell {
Expand All @@ -23,21 +21,6 @@ func localShell() *shell.Shell {
return res
}

func mockShell(filename string, opts ...shell.ShellOption) *shell.Shell {
path, _ := filepath.Abs(filename)
runtime, err := mock.NewFromTomlFile(path)
if err != nil {
panic(err.Error())
}

res, err := shell.New(runtime, opts...)
if err != nil {
panic(err.Error())
}

return res
}

func TestShell_RunOnce(t *testing.T) {
shell := localShell()
assert.NotPanics(t, func() {
Expand Down Expand Up @@ -65,7 +48,7 @@ func TestShell_Help(t *testing.T) {
}

func TestShell_Centos8(t *testing.T) {
shell := mockShell("../../mql/testdata/centos8.toml")
shell := localShell()
assert.NotPanics(t, func() {
shell.RunOnce("platform { title name release arch }")
}, "should not panic on partial queries")
Expand Down
15 changes: 11 additions & 4 deletions providers-sdk/v1/inventory/manager/credentials_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mondoo.com/cnquery/llx"
"go.mondoo.com/cnquery/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/providers-sdk/v1/inventory/manager"
"go.mondoo.com/cnquery/providers-sdk/v1/testutils"
"go.mondoo.com/cnquery/providers-sdk/v1/vault"
"go.mondoo.com/cnquery/providers/mock"
)

var runtime llx.Runtime

func init() {
runtime = testutils.LinuxMock()
}

func TestSecretKeySimple(t *testing.T) {
query := `{ type: 'ssh_agent' }`
runner, err := manager.NewCredentialQueryRunner(query, mock.New())
runner, err := manager.NewCredentialQueryRunner(query, runtime)
require.NoError(t, err)
cred, err := runner.Run(&inventory.Asset{})
require.NoError(t, err)
Expand All @@ -31,7 +38,7 @@ func TestSecretKeyIfReturn(t *testing.T) {
return {type: 'private_key', secret_id: 'otherkey'}
`

runner, err := manager.NewCredentialQueryRunner(query, mock.New())
runner, err := manager.NewCredentialQueryRunner(query, runtime)
require.NoError(t, err)

cred, err := runner.Run(&inventory.Asset{
Expand All @@ -53,7 +60,7 @@ func TestSecretKeyIfConditionalReturn(t *testing.T) {
return { secret_id: '' }"
`

runner, err := manager.NewCredentialQueryRunner(query, mock.New())
runner, err := manager.NewCredentialQueryRunner(query, runtime)
require.NoError(t, err)

// check with provided label
Expand Down
14 changes: 0 additions & 14 deletions providers-sdk/v1/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"go.mondoo.com/cnquery/providers-sdk/v1/lr/docs"
"go.mondoo.com/cnquery/providers-sdk/v1/resources"
"go.mondoo.com/cnquery/providers-sdk/v1/testutils/mockprovider"
"go.mondoo.com/cnquery/providers/mock"
networkconf "go.mondoo.com/cnquery/providers/network/config"
networkprovider "go.mondoo.com/cnquery/providers/network/provider"
osconf "go.mondoo.com/cnquery/providers/os/config"
Expand Down Expand Up @@ -70,15 +69,6 @@ func getEnvFeatures() cnquery.Features {
return fts
}

func TomlMock(filepath string) llx.Runtime {
trans, err := mock.NewFromTomlFile(filepath)
if err != nil {
panic(err.Error())
}

return trans
}

type tester struct {
Runtime llx.Runtime
}
Expand Down Expand Up @@ -289,10 +279,6 @@ func RecordingMock(absTestdataPath string) llx.Runtime {
return mockRuntimeAbs(absTestdataPath)
}

func CustomMock(path string) llx.Runtime {
return TomlMock(path)
}

type SimpleTest struct {
Code string
ResultIndex int
Expand Down
275 changes: 0 additions & 275 deletions providers/mock/mock.go

This file was deleted.

Loading