-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20426 from imiosga/b-aws_amplify_branch-name_symm…
…etry-20410 Fix branch name symmetry issue for Amplify
- Loading branch information
Showing
3 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
aws/resource_aws_amplify_branch: Correctly handle branch names that contain '/' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package amplify_test | ||
|
||
import ( | ||
"testing" | ||
|
||
tfamplify "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/amplify" | ||
) | ||
|
||
func TestBranchParseResourceID(t *testing.T) { | ||
testCases := []struct { | ||
TestName string | ||
InputID string | ||
ExpectError bool | ||
ExpectedAppID string | ||
ExpectedBranchName string | ||
}{ | ||
{ | ||
TestName: "empty ID", | ||
InputID: "", | ||
ExpectError: true, | ||
}, | ||
{ | ||
TestName: "incorrect format", | ||
InputID: "test", | ||
ExpectError: true, | ||
}, | ||
{ | ||
TestName: "valid ID", | ||
InputID: tfamplify.BranchCreateResourceID("appID", "branchName"), | ||
ExpectedAppID: "appID", | ||
ExpectedBranchName: "branchName", | ||
}, | ||
{ | ||
TestName: "valid ID one slash", | ||
InputID: tfamplify.BranchCreateResourceID("appID", "part1/part_2"), | ||
ExpectedAppID: "appID", | ||
ExpectedBranchName: "part1/part_2", | ||
}, | ||
{ | ||
TestName: "valid ID three slashes", | ||
InputID: tfamplify.BranchCreateResourceID("appID", "part1/part_2/part-3/part4"), | ||
ExpectedAppID: "appID", | ||
ExpectedBranchName: "part1/part_2/part-3/part4", | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
t.Run(testCase.TestName, func(t *testing.T) { | ||
gotAppID, gotBranchName, err := tfamplify.BranchParseResourceID(testCase.InputID) | ||
|
||
if err == nil && testCase.ExpectError { | ||
t.Fatalf("expected error") | ||
} | ||
|
||
if err != nil && !testCase.ExpectError { | ||
t.Fatalf("unexpected error") | ||
} | ||
|
||
if gotAppID != testCase.ExpectedAppID { | ||
t.Errorf("got AppID %s, expected %s", gotAppID, testCase.ExpectedAppID) | ||
} | ||
|
||
if gotBranchName != testCase.ExpectedBranchName { | ||
t.Errorf("got BranchName %s, expected %s", gotBranchName, testCase.ExpectedBranchName) | ||
} | ||
}) | ||
} | ||
} |