providers/aws: test S3 policy unmarshaled JSON

This commit is contained in:
Justin Campbell 2015-05-16 05:49:04 -04:00
parent 9c764a3253
commit 4b17554993

View File

@ -1,8 +1,10 @@
package aws package aws
import ( import (
"encoding/json"
"fmt" "fmt"
"math/rand" "math/rand"
"reflect"
"strconv" "strconv"
"testing" "testing"
"time" "time"
@ -195,8 +197,17 @@ func testAccCheckAWSS3BucketPolicy(n string, policy string) resource.TestCheckFu
return fmt.Errorf("bad policy, found nil, expected: %s", policy) return fmt.Errorf("bad policy, found nil, expected: %s", policy)
} }
} else { } else {
if *v != policy { expected := make(map[string]interface{})
return fmt.Errorf("bad policy, expected: %s, got %#v", policy, *v) if err := json.Unmarshal([]byte(policy), &expected); err != nil {
return err
}
actual := make(map[string]interface{})
if err := json.Unmarshal([]byte(*v), &actual); err != nil {
return err
}
if !reflect.DeepEqual(expected, actual) {
return fmt.Errorf("bad policy, expected: %#v, got %#v", expected, actual)
} }
} }