Skip to content

Commit

Permalink
fix: nil checks for source location optional params
Browse files Browse the repository at this point in the history
OTT-6870
  • Loading branch information
thatsddr committed Dec 19, 2024
1 parent 898bde5 commit 41aa352
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
8 changes: 6 additions & 2 deletions awsmt/helpers_source_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ func getCreateSourceLocationInput(model sourceLocationModel) mediatailor.CreateS
var params mediatailor.CreateSourceLocationInput

// Access Configuration
params.AccessConfiguration = getAccessConfigurationInput(model.AccessConfiguration)
if model.AccessConfiguration != nil {
params.AccessConfiguration = getAccessConfigurationInput(model.AccessConfiguration)
}

// Default Segment Delivery Configuration
params.DefaultSegmentDeliveryConfiguration = getDefaultSegmentDeliveryConfigurationInput(model.DefaultSegmentDeliveryConfiguration)
if model.DefaultSegmentDeliveryConfiguration != nil {
params.DefaultSegmentDeliveryConfiguration = getDefaultSegmentDeliveryConfigurationInput(model.DefaultSegmentDeliveryConfiguration)
}

// HTTP Configuration
params.HttpConfiguration = getHttpConfigurationInput(model.HttpConfiguration)
Expand Down
36 changes: 36 additions & 0 deletions awsmt/resource_source_location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ import (
"testing"
)

func TestAccSourceLocationResourceMinimal(t *testing.T) {
resourceName := "awsmt_source_location.test_source_location"
name := "minimalSourceLocation"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: minimalSourceLocation(name),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "id", name),
resource.TestCheckResourceAttr(resourceName, "default_segment_delivery_configuration.base_url", "https://ott-mediatailor-test.s3.eu-central-1.amazonaws.com"),
),
},
},
})
}

func TestAccSourceLocationResourceBasic(t *testing.T) {
resourceName := "awsmt_source_location.test_source_location"
name := "test_source_location"
Expand Down Expand Up @@ -130,6 +148,24 @@ func TestAccSourceLocationDeleteVodResource(t *testing.T) {
})
}

func minimalSourceLocation(name string) string {
return fmt.Sprintf(`
resource "awsmt_source_location" "test_source_location"{
name = "%[1]s"
http_configuration = {
base_url = "https://ott-mediatailor-test.s3.eu-central-1.amazonaws.com"
}
}
data "awsmt_source_location" "read" {
name = awsmt_source_location.test_source_location.name
}
output "awsmt_source_location" {
value = data.awsmt_source_location.read
}
`, name)

}

func basicSourceLocation(name, baseUrl, k1, v1, k2, v2 string) string {
return fmt.Sprintf(`
resource "awsmt_source_location" "test_source_location"{
Expand Down

0 comments on commit 41aa352

Please sign in to comment.