Skip to content

Commit 519bb26

Browse files
committed
internal/function(test): split user_agent cases
```console % TF_ACC=1 go test -v ./internal/function/... -run=TestUserAgentFunction_ 2025/12/10 15:15:39 Creating Terraform AWS Provider (SDKv2-style)... 2025/12/10 15:15:39 Initializing Terraform AWS Provider (SDKv2-style)... --- PASS: TestUserAgentFunction_invalid (1.32s) --- PASS: TestUserAgentFunction_valid_name (7.90s) --- PASS: TestUserAgentFunction_valid (7.93s) --- PASS: TestUserAgentFunction_valid_nameVersion (7.98s) --- PASS: TestUserAgentFunction_valid_nameComment (8.00s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/function 14.469s ```
1 parent 05fc8fc commit 519bb26

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

internal/function/user_agent_test.go

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
1515
)
1616

17-
func TestUserAgentFunction_basic(t *testing.T) {
17+
func TestUserAgentFunction_valid(t *testing.T) {
1818
t.Parallel()
1919

2020
resource.UnitTest(t, resource.TestCase{
@@ -29,18 +29,57 @@ func TestUserAgentFunction_basic(t *testing.T) {
2929
resource.TestCheckOutput("test", "test-module/0.0.1 (test comment)"),
3030
),
3131
},
32+
},
33+
})
34+
}
35+
36+
func TestUserAgentFunction_valid_name(t *testing.T) {
37+
t.Parallel()
38+
39+
resource.UnitTest(t, resource.TestCase{
40+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
41+
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
42+
tfversion.SkipBelow(version.Must(version.NewVersion("1.8.0"))),
43+
},
44+
Steps: []resource.TestStep{
3245
{
33-
Config: testUserAgentFunctionConfig("test-module", "0.0.1", ""),
46+
Config: testUserAgentFunctionConfig("test-module", "", ""),
3447
Check: resource.ComposeAggregateTestCheckFunc(
35-
resource.TestCheckOutput("test", "test-module/0.0.1"),
48+
resource.TestCheckOutput("test", "test-module"),
3649
),
3750
},
51+
},
52+
})
53+
}
54+
55+
func TestUserAgentFunction_valid_nameVersion(t *testing.T) {
56+
t.Parallel()
57+
58+
resource.UnitTest(t, resource.TestCase{
59+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
60+
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
61+
tfversion.SkipBelow(version.Must(version.NewVersion("1.8.0"))),
62+
},
63+
Steps: []resource.TestStep{
3864
{
39-
Config: testUserAgentFunctionConfig("test-module", "", ""),
65+
Config: testUserAgentFunctionConfig("test-module", "0.0.1", ""),
4066
Check: resource.ComposeAggregateTestCheckFunc(
41-
resource.TestCheckOutput("test", "test-module"),
67+
resource.TestCheckOutput("test", "test-module/0.0.1"),
4268
),
4369
},
70+
},
71+
})
72+
}
73+
74+
func TestUserAgentFunction_valid_nameComment(t *testing.T) {
75+
t.Parallel()
76+
77+
resource.UnitTest(t, resource.TestCase{
78+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
79+
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
80+
tfversion.SkipBelow(version.Must(version.NewVersion("1.8.0"))),
81+
},
82+
Steps: []resource.TestStep{
4483
{
4584
Config: testUserAgentFunctionConfig("test-module", "", "test comment"),
4685
Check: resource.ComposeAggregateTestCheckFunc(
@@ -51,7 +90,7 @@ func TestUserAgentFunction_basic(t *testing.T) {
5190
})
5291
}
5392

54-
func TestUserAgentFunction_missingName(t *testing.T) {
93+
func TestUserAgentFunction_invalid(t *testing.T) {
5594
t.Parallel()
5695

5796
resource.UnitTest(t, resource.TestCase{

0 commit comments

Comments
 (0)