Skip to content

Commit

Permalink
(hashicorp#11986) Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
zmeggyesi committed Feb 11, 2020
1 parent b8f8fd4 commit f577779
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions aws/cloudfront_distribution_configuration_structure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ func loggingConfigConf() map[string]interface{} {
}
}

func loggingConfigConfDisabled() map[string]interface{} {
return map[string]interface{}{
"include_cookies": false,
"bucket": "mylogs.s3.amazonaws.com",
"prefix": "myprefix",
"enabled": false,
}
}

func customErrorResponsesConfSet() *schema.Set {
return schema.NewSet(customErrorResponseHash, customErrorResponsesConf())
}
Expand Down Expand Up @@ -848,6 +857,24 @@ func TestCloudFrontStructure_expandLoggingConfig(t *testing.T) {
}
}

func TestCloudFrontStructure_expandLoggingConfigDisabled(t *testing.T) {
data := loggingConfigConfDisabled()

lc := expandLoggingConfig(data)
if *lc.Enabled {
t.Fatalf("Expected Enabled to be false, got %v", *lc.Enabled)
}
if *lc.Prefix != "myprefix" {
t.Fatalf("Expected Prefix to be myprefix, got %v", *lc.Prefix)
}
if *lc.Bucket != "mylogs.s3.amazonaws.com" {
t.Fatalf("Expected Bucket to be mylogs.s3.amazonaws.com, got %v", *lc.Bucket)
}
if *lc.IncludeCookies {
t.Fatalf("Expected IncludeCookies to be false, got %v", *lc.IncludeCookies)
}
}

func TestCloudFrontStructure_expandLoggingConfig_nilValue(t *testing.T) {
lc := expandLoggingConfig(nil)
if *lc.Enabled {
Expand Down

0 comments on commit f577779

Please sign in to comment.