<commit_before>package gogobosh_test

import (
	gogobosh "github.com/cloudfoundry-community/gogobosh"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"net/http"
)

var _ = Describe("Deployments", func() {
	It("GetDeployments() - list of deployments", func() {
		request := gogobosh.NewDirectorTestRequest(gogobosh.TestRequest{
			Method: "GET",
			Path:   "/deployments",
			Response: gogobosh.TestResponse{
				Status: http.StatusOK,
				Body: `[
				  {
				    "name": "cf-warden",
				    "deployments": [
				      {
				        "name": "cf",
				        "version": "153"
				      }
				    ],
				    "stemcells": [
				      {
				        "name": "bosh-stemcell",
				        "version": "993"
				      }
				    ]
				  }
				]`}})
		ts, handler, repo := createDirectorRepo(request)
		defer ts.Close()

		deployments, apiResponse := repo.GetDeployments()

		deployment := deployments[0]
		Expect(deployment.Name).To(Equal("cf-warden"))

		deployment_release := deployment.Releases[0]
		Expect(deployment_release.Name).To(Equal("cf"))
		Expect(deployment_release.Version).To(Equal("153"))

		deployment_stemcell := deployment.Stemcells[0]
		Expect(deployment_stemcell.Name).To(Equal("bosh-stemcell"))
		Expect(deployment_stemcell.Version).To(Equal("993"))

		Expect(apiResponse.IsSuccessful()).To(Equal(true))
		Expect(handler.AllRequestsCalled()).To(Equal(true))
	})

	It("DeleteDeployment(name) forcefully", func() {
		request := gogobosh.NewDirectorTestRequest(gogobosh.TestRequest{
			Method: "DELETE",
			Path:   "/deployments/cf-warden?force=true",
			Response: gogobosh.TestResponse{
				Status: http.StatusFound,
				Header: http.Header{
					"Location":{"https://some.host/tasks/20"},
				},
			}})
		queuedTaskRequest := gogobosh.NewDirectorTestRequest(gogobosh.TestRequest{
			Method: "GET",
			Path:   "/tasks/20",
			Response: gogobosh.TestResponse{
				Status: http.StatusOK,
				Body: `{
				  "id": 20,
				  "state": "queued",
				  "description": "delete deployment cf-warden",
				  "timestamp": 1390174354,
				  "result": null,
				  "user": "admin"
				}`}})
		doneTaskRequest := gogobosh.NewDirectorTestRequest(gogobosh.TestRequest{
			Method: "GET",
			Path:   "/tasks/20",
			Response: gogobosh.TestResponse{
				Status: http.StatusOK,
				Body: `{
				  "id": 12,
				  "state": "done",
				  "description": "delete deployment cf-warden",
				  "timestamp": 1390174354,
				  "result": null,
				  "user": "admin"
				}`}})
		ts, handler, repo := createDirectorRepo(request, queuedTaskRequest, doneTaskRequest)
		defer ts.Close()

		apiResponse := repo.DeleteDeployment("cf-warden")

		Expect(apiResponse.IsSuccessful()).To(Equal(true))
		Expect(handler.AllRequestsCalled()).To(Equal(true))
	})
})<commit_msg>test extra task status step<commit_after>package gogobosh_test

import (
	gogobosh "github.com/cloudfoundry-community/gogobosh"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"net/http"
)

var _ = Describe("Deployments", func() {
	It("GetDeployments() - list of deployments", func() {
		request := gogobosh.NewDirectorTestRequest(gogobosh.TestRequest{
			Method: "GET",
			Path:   "/deployments",
			Response: gogobosh.TestResponse{
				Status: http.StatusOK,
				Body: `[
				  {
				    "name": "cf-warden",
				    "deployments": [
				      {
				        "name": "cf",
				        "version": "153"
				      }
				    ],
				    "stemcells": [
				      {
				        "name": "bosh-stemcell",
				        "version": "993"
				      }
				    ]
				  }
				]`}})
		ts, handler, repo := createDirectorRepo(request)
		defer ts.Close()

		deployments, apiResponse := repo.GetDeployments()

		deployment := deployments[0]
		Expect(deployment.Name).To(Equal("cf-warden"))

		deployment_release := deployment.Releases[0]
		Expect(deployment_release.Name).To(Equal("cf"))
		Expect(deployment_release.Version).To(Equal("153"))

		deployment_stemcell := deployment.Stemcells[0]
		Expect(deployment_stemcell.Name).To(Equal("bosh-stemcell"))
		Expect(deployment_stemcell.Version).To(Equal("993"))

		Expect(apiResponse.IsSuccessful()).To(Equal(true))
		Expect(handler.AllRequestsCalled()).To(Equal(true))
	})

	It("DeleteDeployment(name) forcefully", func() {
		request := gogobosh.NewDirectorTestRequest(gogobosh.TestRequest{
			Method: "DELETE",
			Path:   "/deployments/cf-warden?force=true",
			Response: gogobosh.TestResponse{
				Status: http.StatusFound,
				Header: http.Header{
					"Location":{"https://some.host/tasks/20"},
				},
			}})
		queuedTaskRequest := gogobosh.NewDirectorTestRequest(gogobosh.TestRequest{
			Method: "GET",
			Path:   "/tasks/20",
			Response: gogobosh.TestResponse{
				Status: http.StatusOK,
				Body: `{
				  "id": 20,
				  "state": "queued",
				  "description": "delete deployment cf-warden",
				  "timestamp": 1390174354,
				  "result": null,
				  "user": "admin"
				}`}})
		processingTaskRequest := gogobosh.NewDirectorTestRequest(gogobosh.TestRequest{
			Method: "GET",
			Path:   "/tasks/20",
			Response: gogobosh.TestResponse{
				Status: http.StatusOK,
				Body: `{
				  "id": 20,
				  "state": "processing",
				  "description": "delete deployment cf-warden",
				  "timestamp": 1390174354,
				  "result": null,
				  "user": "admin"
				}`}})
		doneTaskRequest := gogobosh.NewDirectorTestRequest(gogobosh.TestRequest{
			Method: "GET",
			Path:   "/tasks/20",
			Response: gogobosh.TestResponse{
				Status: http.StatusOK,
				Body: `{
				  "id": 12,
				  "state": "done",
				  "description": "delete deployment cf-warden",
				  "timestamp": 1390174354,
				  "result": null,
				  "user": "admin"
				}`}})
		ts, handler, repo := createDirectorRepo(request, queuedTaskRequest, processingTaskRequest, doneTaskRequest)
		defer ts.Close()

		apiResponse := repo.DeleteDeployment("cf-warden")

		Expect(apiResponse.IsSuccessful()).To(Equal(true))
		Expect(handler.AllRequestsCalled()).To(Equal(true))
	})
})
{'fraction_non_alphanumeric': 0.1595744680851064, 'fraction_numerical': 0.017561634582911177, 'mean_word_length': 3.3551470588235293, 'pattern_counts': {'":': 46, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1435518', 'n_tokens_mistral': 2529, 'n_tokens_neox': 1990, 'n_words': 308}