/
testing.go
57 lines (51 loc) · 1.48 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
package client
import (
"testing"
"github.com/cloudquery/cq-provider-sdk/logging"
"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{}
func AwsMockTestHelper(t *testing.T, table *schema.Table, builder func(*testing.T, *gomock.Controller) Services, _ TestOptions) {
table.IgnoreInTests = false
t.Helper()
ctrl := gomock.NewController(t)
cfg := `
regions: ["us-east-1"]
accounts:
- id: testAccount
role_arn: ""
aws_debug: false
max_retries: 3
max_backoff: 60
`
// accounts := []Account{
// {ID: "testAccount"},
// }
providertest.TestResource(t, providertest.ResourceTestCase{
Provider: &provider.Provider{
Name: "aws_mock_test_provider",
Version: "development",
Configure: func(logger hclog.Logger, i interface{}) (schema.ClientMeta, diag.Diagnostics) {
c := NewAwsClient(logging.New(&hclog.LoggerOptions{
Level: hclog.Warn,
}))
c.ServicesManager.InitServicesForPartitionAccountAndRegion("aws", "testAccount", "us-east-1", builder(t, ctrl))
c.Partition = "aws"
return &c, nil
},
ResourceMap: map[string]*schema.Table{
"test_resource": table,
},
Config: func() provider.Config {
return &Config{}
},
},
Config: cfg,
SkipIgnoreInTest: true,
})
}