<commit_before>package action_test

import (
	"errors"

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

	. "github.com/maximilien/bosh-softlayer-cpi/action"

	fakevm "github.com/maximilien/bosh-softlayer-cpi/softlayer/vm/fakes"
)

var _ = Describe("RebootVM", func() {
	var (
		vmFinder *fakevm.FakeFinder
		action   RebootVM
	)

	BeforeEach(func() {
		vmFinder = &fakevm.FakeFinder{}
		action = NewRebootVM(vmFinder)
	})

	Describe("Run", func() {
		It("tries to find vm with given vm cid", func() {
			_, err := action.Run(1234)
			Expect(err).ToNot(HaveOccurred())

			Expect(vmFinder.FindID).To(Equal(1234))
		})

		Context("when vm is found with given vm cid", func() {
			var (
				vm *fakevm.FakeVM
			)

			BeforeEach(func() {
				vm = fakevm.NewFakeVM(1234)
				vmFinder.FindVM = vm
				vmFinder.FindFound = true
			})

			It("reboots vm", func() {
				_, err := action.Run(1234)
				Expect(err).ToNot(HaveOccurred())

				Expect(vm.RebootCalled).To(BeTrue())
			})

			It("returns error if deleting vm fails", func() {
				vm.RebootErr = errors.New("fake-delete-err")

				_, err := action.Run(1234)
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-delete-err"))
			})
		})

		Context("when vm is not found with given cid", func() {
			It("does vmFinder return error", func() {
				vmFinder.FindFound = false

				_, err := action.Run(1234)
				Expect(err).ToNot(HaveOccurred())
			})
		})

		Context("when vm finding fails", func() {
			It("does not return error", func() {
				vmFinder.FindErr = errors.New("fake-find-err")

				_, err := action.Run(1234)
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-find-err"))
			})
		})
	})
})
<commit_msg>fix correct message for reboot vm test<commit_after>package action_test

import (
	"errors"

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

	. "github.com/maximilien/bosh-softlayer-cpi/action"

	fakevm "github.com/maximilien/bosh-softlayer-cpi/softlayer/vm/fakes"
)

var _ = Describe("RebootVM", func() {
	var (
		vmFinder *fakevm.FakeFinder
		action   RebootVM
	)

	BeforeEach(func() {
		vmFinder = &fakevm.FakeFinder{}
		action = NewRebootVM(vmFinder)
	})

	Describe("Run", func() {
		It("tries to find vm with given vm cid", func() {
			_, err := action.Run(1234)
			Expect(err).ToNot(HaveOccurred())

			Expect(vmFinder.FindID).To(Equal(1234))
		})

		Context("when vm is found with given vm cid", func() {
			var (
				vm *fakevm.FakeVM
			)

			BeforeEach(func() {
				vm = fakevm.NewFakeVM(1234)
				vmFinder.FindVM = vm
				vmFinder.FindFound = true
			})

			It("reboots vm", func() {
				_, err := action.Run(1234)
				Expect(err).ToNot(HaveOccurred())

				Expect(vm.RebootCalled).To(BeTrue())
			})

			It("returns error if rebooting vm fails", func() {
				vm.RebootErr = errors.New("fake-reboot-err")

				_, err := action.Run(1234)
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-reboot-err"))
			})
		})

		Context("when vm is not found with given cid", func() {
			It("does vmFinder return error", func() {
				vmFinder.FindFound = false

				_, err := action.Run(1234)
				Expect(err).ToNot(HaveOccurred())
			})
		})

		Context("when vm finding fails", func() {
			It("does not return error", func() {
				vmFinder.FindErr = errors.New("fake-find-err")

				_, err := action.Run(1234)
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake-find-err"))
			})
		})
	})
})

{'fraction_non_alphanumeric': 0.1677124928693668, 'fraction_numerical': 0.015972618368511125, 'mean_word_length': 3.3892365456821025, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6403309', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1293, 'n_words': 228}