"strings"
	"sync"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
	"github.com/rackhd/rackhd-cpi/bosh"
	"github.com/rackhd/rackhd-cpi/config"
	"github.com/rackhd/rackhd-cpi/helpers"
	"github.com/rackhd/rackhd-cpi/rackhdapi"
)

var _ = Describe("The VM Creation Workflow", func() {
	var server *ghttp.Server
	var jsonReader *strings.Reader
	var cpiConfig config.Cpi
	var request bosh.CpiRequest
	var allowFilter Filter

	BeforeEach(func() {
		server, jsonReader, cpiConfig, request = helpers.SetUp(bosh.CREATE_VM)

		allowFilter = Filter{
			data:   nil,
			method: AllowAnyNodeMethod,
		}
	})

	AfterEach(func() {
		server.Close()
	})
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/onsi/gomega/ghttp"
	"github.com/rackhd/rackhd-cpi/bosh"
	"github.com/rackhd/rackhd-cpi/config"
	"github.com/rackhd/rackhd-cpi/cpi"
	"github.com/rackhd/rackhd-cpi/helpers"
	"github.com/rackhd/rackhd-cpi/rackhdapi"
)

var _ = Describe("DeleteVM", func() {
	var server *ghttp.Server
	var jsonReader *strings.Reader
	var cpiConfig config.Cpi
	var request bosh.CpiRequest

	BeforeEach(func() {
		server, jsonReader, cpiConfig, request = helpers.SetUp(bosh.DELETE_VM)
		cpiConfig.RequestID = "requestid"
	})

	AfterEach(func() {
		server.Close()
	})

	Context("with a valid VM CID and valid states", func() {
		var extInput bosh.MethodArguments
		var expectedNodes []rackhdapi.Node
	"time"

	"github.com/nu7hatch/gouuid"
	"github.com/rackhd/rackhd-cpi/config"
	"github.com/rackhd/rackhd-cpi/helpers"
	"github.com/rackhd/rackhd-cpi/rackhdapi"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Workflows", func() {
	var server *ghttp.Server
	var jsonReader *strings.Reader
	var cpiConfig config.Cpi

	BeforeEach(func() {
		server, jsonReader, cpiConfig, _ = helpers.SetUp("")
	})

	AfterEach(func() {
		server.Close()
	})

	Describe("GetActiveWorkflows", func() {
		Context("there is a running workflow", func() {
			It("returns a node's active workflow", func() {
				rawWorkflow := helpers.LoadJSON("../spec_assets/dummy_workflow_response.json")
				httpResponse := []byte(fmt.Sprintf("%s", string(rawWorkflow)))
				var expectedResponse rackhdapi.WorkflowResponse
	"net/http"
	"strings"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"
	"github.com/rackhd/rackhd-cpi/bosh"
	"github.com/rackhd/rackhd-cpi/config"
	"github.com/rackhd/rackhd-cpi/cpi"
	"github.com/rackhd/rackhd-cpi/helpers"
)

var _ = Describe("CreateDisk", func() {
	var server *ghttp.Server
	var jsonReader *strings.Reader
	var cpiConfig config.Cpi
	var request bosh.CpiRequest

	BeforeEach(func() {
		server, jsonReader, cpiConfig, request = helpers.SetUp(bosh.CREATE_DISK)
		cpiConfig.RequestID = "my_id"
	})

	AfterEach(func() {
		server.Close()
	})

	Context("If VM cid cannot be found", func() {
		It("returns error", func() {
			jsonInput := []byte(`[
					25000,