Skip to content

Commit

Permalink
Add ReplaceRouteTable methods & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheath committed Apr 2, 2014
1 parent 6f54e50 commit b309429
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ec2/responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,3 +822,10 @@ var AssociateRouteTableExample = `
<associationId>rtbassoc-f8ad4891</associationId>
</AssociateRouteTableResponse>
`

var ReplaceRouteTableAssociationExample = `
<ReplaceRouteTableAssociationResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
<requestId>59dbff89-35bd-4eac-88ed-be587EXAMPLE</requestId>
<newAssociationId>rtbassoc-faad2958</newAssociationId>
</ReplaceRouteTableAssociationResponse>
`
23 changes: 23 additions & 0 deletions ec2/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,26 @@ func (ec2 *EC2) AssociateRouteTable(routeTableId, subnetId string) (resp *Associ
}
return
}

// ReplaceRouteTableAssociationResp represents a response from a ReplaceRouteTableAssociation call
//
// See for more details.
type ReplaceRouteTableAssociationResp struct {
RequestId string `xml:"requestId"`
NewAssociationId string `xml:"newAssociationId"`
}

// ReplaceRouteTableAssociation changes the route table associated with a given subnet in a VPC.
//
// See for more details.
func (ec2 *EC2) ReplaceRouteTableAssociation(associationId, routeTableId string) (resp *ReplaceRouteTableAssociationResp, err error) {
params := makeParams("ReplaceRouteTableAssociation")
params["AssociationId"] = associationId
params["RouteTableId"] = routeTableId
resp = &ReplaceRouteTableAssociationResp{}
err = ec2.query(params, resp)
if err != nil {
return nil, err
}
return
}
15 changes: 15 additions & 0 deletions ec2/vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,18 @@ func (s *S) TestAssociateRouteTable(c *gocheck.C) {
c.Assert(resp.RequestId, gocheck.Equals, "59dbff89-35bd-4eac-99ed-be587EXAMPLE")
c.Assert(resp.AssociationId, gocheck.Equals, "rtbassoc-f8ad4891")
}

func (s *S) TestReplaceRouteTableAssociation(c *gocheck.C) {
testServer.Response(200, nil, ReplaceRouteTableAssociationExample)

resp, err := s.ec2.ReplaceRouteTableAssociation("rtbassoc-f8ad4891", "rtb-f9ad4890")

req := testServer.WaitRequest()
c.Assert(req.Form["Action"], gocheck.DeepEquals, []string{"ReplaceRouteTableAssociation"})
c.Assert(req.Form["RouteTableId"], gocheck.DeepEquals, []string{"rtb-f9ad4890"})
c.Assert(req.Form["AssociationId"], gocheck.DeepEquals, []string{"rtbassoc-f8ad4891"})

c.Assert(err, gocheck.IsNil)
c.Assert(resp.RequestId, gocheck.Equals, "59dbff89-35bd-4eac-88ed-be587EXAMPLE")
c.Assert(resp.NewAssociationId, gocheck.Equals, "rtbassoc-faad2958")
}

0 comments on commit b309429

Please sign in to comment.