This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtesting.go
63 lines (56 loc) · 1.58 KB
/
testing.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package client
import (
"testing"
"github.com/cloudquery/cq-provider-sdk/provider"
"github.com/cloudquery/cq-provider-sdk/provider/diag"
"github.com/cloudquery/cq-provider-sdk/provider/schema"
providertest "github.com/cloudquery/cq-provider-sdk/provider/testing"
"github.com/golang/mock/gomock"
"github.com/hashicorp/go-hclog"
)
type TestOptions struct {
SkipEmptyJsonB bool
}
func K8sTestHelper(t *testing.T, table *schema.Table, snapshotDirPath string) {
cfg := ``
providertest.TestResource(t, providertest.ResourceTestCase{
Provider: &provider.Provider{
Name: "k8s_mock_test_provider",
Version: "development",
Configure: Configure,
Config: func() provider.Config {
return &Config{}
},
ResourceMap: map[string]*schema.Table{
"test_resource": table,
},
},
Config: cfg,
})
}
func K8sMockTestHelper(t *testing.T, table *schema.Table, builder func(*testing.T, *gomock.Controller) Services, options TestOptions) {
t.Helper()
ctrl := gomock.NewController(t)
cfg := ``
providertest.TestResource(t, providertest.ResourceTestCase{
Provider: &provider.Provider{
Name: "k8s_mock_test_provider",
Version: "development",
Configure: func(logger hclog.Logger, _ interface{}) (schema.ClientMeta, diag.Diagnostics) {
c := &Client{
Log: logger,
Context: "testContext",
}
c.SetServices(map[string]Services{"testContext": builder(t, ctrl)})
return c, nil
},
ResourceMap: map[string]*schema.Table{
"test_resource": table,
},
Config: func() provider.Config {
return &Config{}
},
},
Config: cfg,
})
}