func TestResourceFastlyFlattenBackend(t *testing.T) {
	cases := []struct {
		remote []*gofastly.Backend
		local  []map[string]interface{}
	}{
		{
			remote: []*gofastly.Backend{
				&gofastly.Backend{
					Name:                "test.notexample.com",
					Address:             "www.notexample.com",
					Port:                uint(80),
					AutoLoadbalance:     true,
					BetweenBytesTimeout: uint(10000),
					ConnectTimeout:      uint(1000),
					ErrorThreshold:      uint(0),
					FirstByteTimeout:    uint(15000),
					MaxConn:             uint(200),
					RequestCondition:    "",
					SSLCheckCert:        true,
					SSLHostname:         "",
					Shield:              "New York",
					Weight:              uint(100),
				},
			},
			local: []map[string]interface{}{
				map[string]interface{}{
					"name":                  "test.notexample.com",
					"address":               "www.notexample.com",
					"port":                  80,
					"auto_loadbalance":      gofastly.CBool(true),
					"between_bytes_timeout": 10000,
					"connect_timeout":       1000,
					"error_threshold":       0,
					"first_byte_timeout":    15000,
					"max_conn":              200,
					"request_condition":     "",
					"ssl_check_cert":        gofastly.CBool(true),
					"ssl_hostname":          "",
					"shield":                "New York",
					"weight":                100,
				},
			},
		},
	}

	for _, c := range cases {
		out := flattenBackends(c.remote)
		if !reflect.DeepEqual(out, c.local) {
			t.Fatalf("Error matching:\nexpected: %#v\ngot: %#v", c.local, out)
		}
	}
}
func TestFastlyServiceV1_BuildHeaders(t *testing.T) {
	cases := []struct {
		remote *gofastly.CreateHeaderInput
		local  map[string]interface{}
	}{
		{
			remote: &gofastly.CreateHeaderInput{
				Name:        "someheadder",
				Action:      gofastly.HeaderActionDelete,
				IgnoreIfSet: gofastly.CBool(true),
				Type:        gofastly.HeaderTypeCache,
				Destination: "http.aws-id",
				Priority:    uint(100),
			},
			local: map[string]interface{}{
				"name":               "someheadder",
				"action":             "delete",
				"ignore_if_set":      true,
				"destination":        "http.aws-id",
				"priority":           100,
				"source":             "",
				"regex":              "",
				"substitution":       "",
				"request_condition":  "",
				"cache_condition":    "",
				"response_condition": "",
				"type":               "cache",
			},
		},
		{
			remote: &gofastly.CreateHeaderInput{
				Name:        "someheadder",
				Action:      gofastly.HeaderActionSet,
				IgnoreIfSet: gofastly.CBool(false),
				Type:        gofastly.HeaderTypeCache,
				Destination: "http.aws-id",
				Priority:    uint(100),
				Source:      "http.server-name",
			},
			local: map[string]interface{}{
				"name":               "someheadder",
				"action":             "set",
				"ignore_if_set":      false,
				"destination":        "http.aws-id",
				"priority":           100,
				"source":             "http.server-name",
				"regex":              "",
				"substitution":       "",
				"request_condition":  "",
				"cache_condition":    "",
				"response_condition": "",
				"type":               "cache",
			},
		},
	}

	for _, c := range cases {
		out, _ := buildHeader(c.local)
		if !reflect.DeepEqual(out, c.remote) {
			t.Fatalf("Error matching:\nexpected: %#v\ngot: %#v", c.remote, out)
		}
	}
}