From b6645a8e32bf884870e2f97ab54d87076035cea3 Mon Sep 17 00:00:00 2001 From: Long Nguyen Date: Wed, 20 Jul 2016 11:53:20 -0700 Subject: [PATCH] add has release --- deployment.go | 11 +++++++++++ deployment_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 deployment.go create mode 100644 deployment_test.go diff --git a/deployment.go b/deployment.go new file mode 100644 index 0000000..346417c --- /dev/null +++ b/deployment.go @@ -0,0 +1,11 @@ +package gogobosh + +// HasRelease if deployment has release +func (d *Deployment) HasRelease(name string) bool { + for _, release := range d.Releases { + if release.Name == name { + return true + } + } + return false +} diff --git a/deployment_test.go b/deployment_test.go new file mode 100644 index 0000000..cc53780 --- /dev/null +++ b/deployment_test.go @@ -0,0 +1,28 @@ +package gogobosh_test + +import ( + . "github.com/cloudfoundry-community/gogobosh" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Deployment", func() { + Describe("Test Deployment", func() { + + Describe("Test if release exist", func() { + + It("see if release exist", func() { + deployment := &Deployment{ + Releases: []Resource{ + Resource{ + Name: "test", + }, + }, + } + Expect(deployment.HasRelease("test")).Should(Equal(true)) + Expect(deployment.HasRelease("bad")).Should(Equal(false)) + }) + }) + + }) +})