<commit_before>package lifecycle_test

import (
	"github.com/cloudfoundry-incubator/garden"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Lifecycle", func() {
	Describe("handle collisions", func() {
		var c garden.Container

		AfterEach(func() {
			err := client.Destroy(c.Handle())
			Expect(err).ShouldNot(HaveOccurred())
		})
		It("returns an error", func() {
			var err error
			client = startGarden()
			c, err = client.Create(garden.ContainerSpec{})
			Expect(err).NotTo(HaveOccurred())
			_, err = client.Create(garden.ContainerSpec{Handle: c.Handle()})
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(Equal("handle already exists: foo"))
		})
	})
})
<commit_msg>Add an integration test for [#92705374]<commit_after>package lifecycle_test

import (
	"bytes"
	"os"

	"github.com/cloudfoundry-incubator/garden"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Lifecycle", func() {
	var c garden.Container
	var err error

	JustBeforeEach(func() {
		client = startGarden()
		c, err = client.Create(garden.ContainerSpec{})
		Expect(err).ToNot(HaveOccurred())
	})

	AfterEach(func() {
		err := client.Destroy(c.Handle())
		Expect(err).ShouldNot(HaveOccurred())
	})

	Describe("process pid", func() {

		It("returns the pid", func() {
			tarFile, err := os.Open("../bin/consume.tar.gz")
			Expect(err).ShouldNot(HaveOccurred())
			defer tarFile.Close()

			err = c.StreamIn("bin", tarFile)
			Expect(err).ShouldNot(HaveOccurred())

			buf := make([]byte, 0, 1024*1024)
			stdout := bytes.NewBuffer(buf)

			process, err := c.Run(garden.ProcessSpec{
				Path: "bin/consume.exe",
				Args: []string{"64"},
			}, garden.ProcessIO{Stdout: stdout})
			Expect(err).ShouldNot(HaveOccurred())
			// NOTE: we have to cast the pid to uint32, otherwise int(0) !=
			// uint32(0) and the following will be trivially true for any
			// value of the pid
			Expect(process.ID()).ToNot(Equal(uint32(0)))
		})
	})

	Describe("handle collisions", func() {
		It("returns an error", func() {
			_, err := client.Create(garden.ContainerSpec{Handle: c.Handle()})
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(Equal("handle already exists: foo"))
		})
	})
})

{'fraction_non_alphanumeric': 0.1760468257541648, 'fraction_numerical': 0.012606933813597478, 'mean_word_length': 4.215962441314554, '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': '5922759', 'n_tokens_mistral': 885, 'n_tokens_neox': 777, 'n_words': 147}