474
474
// The last request deletes the hosted service.
475
475
assertDeleteHostedServiceRequest(c, api, request.ServiceName, record[5])
478
func (suite *suiteDestroyHostedService) TestOkayWhenHostedServiceNotFound(c *C) {
479
var responses []DispatcherResponse
481
responses = []DispatcherResponse{exampleNotFoundResponse}
482
record := []*X509Request{}
483
rigRecordingPreparedResponseDispatcher(&record, responses)
484
// Exercise DestroyHostedService.
486
request := &DestroyHostedServiceRequest{ServiceName: "service-name"}
487
err := api.DestroyHostedService(request)
489
c.Check(record, HasLen, 1)
492
func (suite *suiteDestroyHostedService) TestOkayWhenDeploymentsNotFound(c *C) {
493
var responses []DispatcherResponse
495
responses = append(responses, makeOKXMLResponse(c, exampleHostedService)...)
496
// Someone else has destroyed the deployments in the meantime.
497
responses = append(responses, exampleNotFoundResponse, exampleNotFoundResponse)
498
// Success deleting the hosted service.
499
responses = append(responses, exampleOkayResponse)
500
record := []*X509Request{}
501
rigRecordingPreparedResponseDispatcher(&record, responses)
502
// Exercise DestroyHostedService.
504
request := &DestroyHostedServiceRequest{ServiceName: "service-name"}
505
err := api.DestroyHostedService(request)
507
c.Check(record, HasLen, 4)
508
assertGetDeploymentRequest(c, api, &GetDeploymentRequest{
509
request.ServiceName, "one"}, record[1])
510
assertGetDeploymentRequest(c, api, &GetDeploymentRequest{
511
request.ServiceName, "two"}, record[2])
512
assertDeleteHostedServiceRequest(c, api, request.ServiceName, record[3])
515
func (suite *suiteDestroyHostedService) TestOkayWhenHostedServiceNotFoundWhenDeleting(c *C) {
516
var responses []DispatcherResponse
518
responses = append(responses, makeOKXMLResponse(c, exampleHostedService)...)
519
// Someone else has destroyed the deployments in the meantime.
520
responses = append(responses, exampleNotFoundResponse, exampleNotFoundResponse)
521
// Someone else has destroyed the hosted service in the meantime.
522
responses = append(responses, exampleNotFoundResponse)
523
record := []*X509Request{}
524
rigRecordingPreparedResponseDispatcher(&record, responses)
525
// Exercise DestroyHostedService.
527
request := &DestroyHostedServiceRequest{ServiceName: "service-name"}
528
err := api.DestroyHostedService(request)
530
c.Check(record, HasLen, 4)
531
assertGetDeploymentRequest(c, api, &GetDeploymentRequest{
532
request.ServiceName, "one"}, record[1])
533
assertGetDeploymentRequest(c, api, &GetDeploymentRequest{
534
request.ServiceName, "two"}, record[2])
535
assertDeleteHostedServiceRequest(c, api, request.ServiceName, record[3])
538
func (suite *suiteDestroyHostedService) TestFailsGettingHostedService(c *C) {
539
var responses []DispatcherResponse
541
responses = []DispatcherResponse{exampleFailResponse}
542
record := []*X509Request{}
543
rigRecordingPreparedResponseDispatcher(&record, responses)
544
// Exercise DestroyHostedService.
546
request := &DestroyHostedServiceRequest{ServiceName: "service-name"}
547
err := api.DestroyHostedService(request)
548
c.Assert(err, NotNil)
549
c.Check(err, ErrorMatches, "GET request failed [(]500: Internal Server Error[)]")
550
c.Check(record, HasLen, 1)
553
func (suite *suiteDestroyHostedService) TestFailsDestroyingDeployment(c *C) {
554
var responses []DispatcherResponse
556
responses = append(responses, makeOKXMLResponse(c, exampleHostedService)...)
557
responses = append(responses, exampleFailResponse)
558
record := []*X509Request{}
559
rigRecordingPreparedResponseDispatcher(&record, responses)
560
// Exercise DestroyHostedService.
562
request := &DestroyHostedServiceRequest{ServiceName: "service-name"}
563
err := api.DestroyHostedService(request)
564
c.Assert(err, NotNil)
565
c.Check(err, ErrorMatches, "GET request failed [(]500: Internal Server Error[)]")
566
c.Check(record, HasLen, 2)
569
func (suite *suiteDestroyHostedService) TestFailsDeletingHostedService(c *C) {
570
var responses []DispatcherResponse
572
responses = append(responses, makeOKXMLResponse(c, exampleHostedService)...)
573
// Deployments not found, but that's okay.
574
responses = append(responses, exampleNotFoundResponse, exampleNotFoundResponse)
575
// When deleting hosted service.
576
responses = append(responses, exampleFailResponse)
577
record := []*X509Request{}
578
rigRecordingPreparedResponseDispatcher(&record, responses)
579
// Exercise DestroyHostedService.
581
request := &DestroyHostedServiceRequest{ServiceName: "service-name"}
582
err := api.DestroyHostedService(request)
583
c.Assert(err, NotNil)
584
c.Check(err, ErrorMatches, "DELETE request failed [(]500: Internal Server Error[)]")
585
c.Check(record, HasLen, 4)