It("has the supplied env vars", func() { Expect(thePreparedCmd.Env).To(ContainElement("foo=bar")) Expect(thePreparedCmd.Env).To(ContainElement("baz=barry")) }) It("sets the USER environment variable", func() { Expect(thePreparedCmd.Env).To(ContainElement("USER=another-user")) }) It("sets the HOME environment variable to the home dir in /etc/passwd", func() { Expect(thePreparedCmd.Env).To(ContainElement("HOME=/the/home/dir")) }) Context("when the Env contains a HOME", func() { BeforeEach(func() { spec.Env = append(spec.Env, "HOME=/nowhere") }) It("sets the HOME environment variable to the value in the Env", func() { Expect(thePreparedCmd.Env).To(ContainElement("HOME=/nowhere")) Expect(thePreparedCmd.Env).ToNot(ContainElement("HOME=/the/home/dir")) }) }) Context("when the ENV does not contain a PATH", func() { Context("and the uid is not 0", func() { It("appends the DefaultUserPATH to the environment", func() { Expect(thePreparedCmd.Env).To(ContainElement(fmt.Sprintf("PATH=%s", container_daemon.DefaultUserPath))) }) })