convert existing release to/from draft

This commit is contained in:
Alex Suraci
2015-10-27 14:47:12 -07:00
parent 657cb152b4
commit d30a1d0197
2 changed files with 29 additions and 0 deletions

View File

@@ -79,6 +79,7 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err
existingRelease.Name = github.String(name)
existingRelease.Body = github.String(body)
existingRelease.TargetCommitish = github.String(targetCommitish)
existingRelease.Draft = github.Bool(draft)
for _, asset := range existingRelease.Assets {
fmt.Fprintf(c.writer, "clearing existing asset: %s\n", *asset.Name)

View File

@@ -112,6 +112,34 @@ var _ = Describe("Out Command", func() {
Ω(githubClient.DeleteReleaseAssetArgsForCall(1)).Should(Equal(existingAssets[1]))
})
Context("when not set as a draft release", func() {
BeforeEach(func() {
request.Source.Drafts = false
})
It("updates the existing release to a non-draft", func() {
Ω(githubClient.UpdateReleaseCallCount()).Should(Equal(1))
updatedRelease := githubClient.UpdateReleaseArgsForCall(0)
Ω(*updatedRelease.Name).Should(Equal("v0.3.12"))
Ω(*updatedRelease.Draft).Should(Equal(false))
})
})
Context("when set as a draft release", func() {
BeforeEach(func() {
request.Source.Drafts = true
})
It("updates the existing release to a draft", func() {
Ω(githubClient.UpdateReleaseCallCount()).Should(Equal(1))
updatedRelease := githubClient.UpdateReleaseArgsForCall(0)
Ω(*updatedRelease.Name).Should(Equal("v0.3.12"))
Ω(*updatedRelease.Draft).Should(Equal(true))
})
})
Context("when a commitish is not supplied", func() {
It("updates the existing release", func() {
Ω(githubClient.UpdateReleaseCallCount()).Should(Equal(1))