-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aws/endpoints: Update unit tests use static data instead of live model (
#4389) Updates the SDK's endpoints model unit tests to ensure that unit tests are performed on static data instead of the live model that can be updated at any time. This change was done to ensure that upstream sources of endpoint models making semantic changes do not cause unit tests to break.
- Loading branch information
Showing
6 changed files
with
18,901 additions
and
323 deletions.
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
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,49 @@ | ||
package endpoints | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
// Update all endpoints partition variables data to be the static testdata | ||
// model instead of the dynamic live model. This ensures that endpoint tests | ||
// are tested against static data, and will not break when the live | ||
// endpoints.json model is updated. | ||
|
||
func TestMain(m *testing.M) { | ||
testdataFilename := filepath.Join("testdata", "endpoints.json") | ||
|
||
testdataFile, err := os.Open(testdataFilename) | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to open test endpoints model, %v", err)) | ||
} | ||
|
||
resolver, err := DecodeModel(testdataFile) | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to decode test endpoints model, %v", err)) | ||
} | ||
|
||
partitions, ok := resolver.(partitions) | ||
if !ok { | ||
panic(fmt.Sprintf("expect %T resolver, got %T", partitions, resolver)) | ||
} | ||
|
||
for _, p := range partitions { | ||
switch p.ID { | ||
case "aws": | ||
awsPartition = p | ||
case "aws-cn": | ||
awscnPartition = p | ||
case "aws-us-gov": | ||
awsusgovPartition = p | ||
case "aws-iso": | ||
awsisoPartition = p | ||
case "aws-iso-b": | ||
awsisobPartition = p | ||
default: | ||
panic("unknown endpoints partition " + p.ID) | ||
} | ||
} | ||
} |
Oops, something went wrong.