Skip to content

Commit 8361ea6

Browse files
committed
test provider
1 parent 2f341cb commit 8361ea6

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package testprovider
5+
6+
import (
7+
"context"
8+
9+
"github.com/hashicorp/terraform-plugin-framework/action"
10+
)
11+
12+
var _ action.ConfigValidator = &ActionConfigValidator{}
13+
14+
// Declarative action.ConfigValidator for unit testing.
15+
type ActionConfigValidator struct {
16+
// ActionConfigValidator interface methods
17+
DescriptionMethod func(context.Context) string
18+
MarkdownDescriptionMethod func(context.Context) string
19+
ValidateActionMethod func(context.Context, action.ValidateConfigRequest, *action.ValidateConfigResponse)
20+
}
21+
22+
// Description satisfies the action.ConfigValidator interface.
23+
func (v *ActionConfigValidator) Description(ctx context.Context) string {
24+
if v.DescriptionMethod == nil {
25+
return ""
26+
}
27+
28+
return v.DescriptionMethod(ctx)
29+
}
30+
31+
// MarkdownDescription satisfies the action.ConfigValidator interface.
32+
func (v *ActionConfigValidator) MarkdownDescription(ctx context.Context) string {
33+
if v.MarkdownDescriptionMethod == nil {
34+
return ""
35+
}
36+
37+
return v.MarkdownDescriptionMethod(ctx)
38+
}
39+
40+
// Validate satisfies the action.ConfigValidator interface.
41+
func (v *ActionConfigValidator) ValidateAction(ctx context.Context, req action.ValidateConfigRequest, resp *action.ValidateConfigResponse) {
42+
if v.ValidateActionMethod == nil {
43+
return
44+
}
45+
46+
v.ValidateActionMethod(ctx, req, resp)
47+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package testprovider
5+
6+
import (
7+
"context"
8+
9+
"github.com/hashicorp/terraform-plugin-framework/action"
10+
)
11+
12+
var _ action.Action = &ActionWithConfigValidators{}
13+
var _ action.ActionWithConfigValidators = &ActionWithConfigValidators{}
14+
15+
// Declarative action.ActionWithConfigValidators for unit testing.
16+
type ActionWithConfigValidators struct {
17+
*Action
18+
19+
// ActionWithConfigValidators interface methods
20+
ConfigValidatorsMethod func(context.Context) []action.ConfigValidator
21+
}
22+
23+
// ConfigValidators satisfies the action.ActionWithConfigValidators interface.
24+
func (p *ActionWithConfigValidators) ConfigValidators(ctx context.Context) []action.ConfigValidator {
25+
if p.ConfigValidatorsMethod == nil {
26+
return nil
27+
}
28+
29+
return p.ConfigValidatorsMethod(ctx)
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package testprovider
5+
6+
import (
7+
"context"
8+
9+
"github.com/hashicorp/terraform-plugin-framework/action"
10+
)
11+
12+
var _ action.Action = &ActionWithValidateConfig{}
13+
var _ action.ActionWithValidateConfig = &ActionWithValidateConfig{}
14+
15+
// Declarative action.ActionWithValidateConfig for unit testing.
16+
type ActionWithValidateConfig struct {
17+
*Action
18+
19+
// ActionWithValidateConfig interface methods
20+
ValidateConfigMethod func(context.Context, action.ValidateConfigRequest, *action.ValidateConfigResponse)
21+
}
22+
23+
// ValidateConfig satisfies the action.ActionWithValidateConfig interface.
24+
func (p *ActionWithValidateConfig) ValidateConfig(ctx context.Context, req action.ValidateConfigRequest, resp *action.ValidateConfigResponse) {
25+
if p.ValidateConfigMethod == nil {
26+
return
27+
}
28+
29+
p.ValidateConfigMethod(ctx, req, resp)
30+
}

0 commit comments

Comments
 (0)