Skip to content

Commit

Permalink
Revert "update test to cover scenario where release download can be s…
Browse files Browse the repository at this point in the history
…kipped"

This reverts commit 05449cb.
  • Loading branch information
rizwanreza committed Jan 9, 2025
1 parent b5ddcab commit b42a5ce
Showing 1 changed file with 8 additions and 66 deletions.
74 changes: 8 additions & 66 deletions internal/commands/update_stemcell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@ var _ = Describe("UpdateStemcell", func() {
release1Version = "1"
release2Name = "release2"
release2Version = "2"
release3Name = "release3"
release3Version = "3"

newRelease1SHA = "new-sha1-1"
newRelease1RemotePath = "new-remote-path-1"
newRelease2SHA = "new-sha1-2"
newRelease2RemotePath = "new-remote-path-2"
newRelease3SHA = "new-sha1-3"
newRelease3RemotePath = "new-remote-path-3"

publishableReleaseSourceID = "publishable"
unpublishableReleaseSourceID = "test-only"
Expand Down Expand Up @@ -70,9 +66,8 @@ var _ = Describe("UpdateStemcell", func() {
Version: "^1",
},
Releases: []cargo.BOSHReleaseTarballSpecification{
{Name: release1Name, GitHubRepository: "https://example.com/lemon", Version: "*"},
{Name: release1Name, GitHubRepository: "https://example.com/lemon", Version: "*"},
{Name: release2Name, GitHubRepository: "https://example.com/orange", Version: "*"},
{Name: release3Name, GitHubRepository: "https://example.com/pomelo", Version: "*"},
},
}
kilnfileLock = cargo.KilnfileLock{
Expand All @@ -91,13 +86,6 @@ var _ = Describe("UpdateStemcell", func() {
RemoteSource: "old-remote-source-2",
RemotePath: "old-remote-path-2",
},
{
Name: release3Name,
Version: release3Version,
SHA1: "old-sha-3",
RemoteSource: "old-remote-source-3",
RemotePath: "old-remote-path-3",
},
},
Stemcell: cargo.Stemcell{
OS: "old-os",
Expand All @@ -113,23 +101,13 @@ var _ = Describe("UpdateStemcell", func() {
Name: release1Name, Version: release1Version,
RemotePath: newRelease1RemotePath,
RemoteSource: publishableReleaseSourceID,
SHA1: "",
}
return remote, nil
case release2Name:
remote := cargo.BOSHReleaseTarballLock{
Name: release2Name, Version: release2Version,
RemotePath: newRelease2RemotePath,
RemoteSource: unpublishableReleaseSourceID,
SHA1: "not-calculated",
}
return remote, nil
case release3Name:
remote := cargo.BOSHReleaseTarballLock{
Name: release3Name, Version: release3Version,
RemotePath: newRelease3RemotePath,
RemoteSource: publishableReleaseSourceID,
SHA1: newRelease3SHA,
}
return remote, nil
default:
Expand All @@ -144,23 +122,13 @@ var _ = Describe("UpdateStemcell", func() {
Name: release1Name, Version: release1Version,
RemotePath: newRelease1RemotePath,
RemoteSource: publishableReleaseSourceID,
SHA1: "",
}
return remote, nil
case release2Name:
remote := cargo.BOSHReleaseTarballLock{
Name: release2Name, Version: release2Version,
RemotePath: newRelease2RemotePath,
RemoteSource: unpublishableReleaseSourceID,
SHA1: "not-calculated",
}
return remote, nil
case release3Name:
remote := cargo.BOSHReleaseTarballLock{
Name: release3Name, Version: release3Version,
RemotePath: newRelease3RemotePath,
RemoteSource: publishableReleaseSourceID,
SHA1: newRelease3SHA,
}
return remote, nil
default:
Expand All @@ -183,7 +151,7 @@ var _ = Describe("UpdateStemcell", func() {
}
return local, nil
default:
panic("unexpected release name '" + remote.Name + "'")
panic("unexpected release name '"+remote.Name +"'")
}
})

Expand Down Expand Up @@ -224,7 +192,7 @@ var _ = Describe("UpdateStemcell", func() {
OS: newStemcellOS,
Version: newStemcellVersion,
}))
Expect(updatedLockfile.Releases).To(HaveLen(3))
Expect(updatedLockfile.Releases).To(HaveLen(2))
Expect(updatedLockfile.Releases).To(ContainElement(
cargo.BOSHReleaseTarballLock{
Name: release1Name,
Expand All @@ -243,15 +211,6 @@ var _ = Describe("UpdateStemcell", func() {
RemotePath: newRelease2RemotePath,
},
))
Expect(updatedLockfile.Releases).To(ContainElement(
cargo.BOSHReleaseTarballLock{
Name: release3Name,
Version: release3Version,
SHA1: newRelease3SHA,
RemoteSource: publishableReleaseSourceID,
RemotePath: newRelease3RemotePath,
},
))
})

It("looks up the correct releases", func() {
Expand All @@ -260,7 +219,7 @@ var _ = Describe("UpdateStemcell", func() {
})
Expect(err).NotTo(HaveOccurred())

Expect(releaseSource.GetMatchedReleaseCallCount()).To(Equal(3))
Expect(releaseSource.GetMatchedReleaseCallCount()).To(Equal(2))

req1 := releaseSource.GetMatchedReleaseArgsForCall(0)
Expect(req1).To(Equal(cargo.BOSHReleaseTarballSpecification{
Expand All @@ -275,21 +234,14 @@ var _ = Describe("UpdateStemcell", func() {
StemcellOS: newStemcellOS, StemcellVersion: newStemcellVersion,
GitHubRepository: "https://example.com/orange",
}))

req3 := releaseSource.GetMatchedReleaseArgsForCall(2)
Expect(req3).To(Equal(cargo.BOSHReleaseTarballSpecification{
Name: release3Name, Version: release3Version,
StemcellOS: newStemcellOS, StemcellVersion: newStemcellVersion,
GitHubRepository: "https://example.com/pomelo",
}))
})
It("looks up the correct releases with --update-releases", func() {
err := update.Execute([]string{
"--kilnfile", kilnfilePath, "--version", "1.100", "--releases-directory", releasesDirPath, "--update-releases",
})
Expect(err).NotTo(HaveOccurred())

Expect(releaseSource.FindReleaseVersionCallCount()).To(Equal(3))
Expect(releaseSource.FindReleaseVersionCallCount()).To(Equal(2))

req1, noDownload1 := releaseSource.FindReleaseVersionArgsForCall(0)
Expect(req1).To(Equal(cargo.BOSHReleaseTarballSpecification{
Expand All @@ -308,7 +260,8 @@ var _ = Describe("UpdateStemcell", func() {
Expect(noDownload2).To(BeTrue())
})

It("downloads 2 of the 3 correct releases, ", func() {

It("downloads the correct releases", func() {
err := update.Execute([]string{
"--kilnfile", kilnfilePath, "--version", newStemcellVersion, "--releases-directory", releasesDirPath,
})
Expand All @@ -323,7 +276,6 @@ var _ = Describe("UpdateStemcell", func() {
Name: release1Name, Version: release1Version,
RemotePath: newRelease1RemotePath,
RemoteSource: publishableReleaseSourceID,
SHA1: "",
},
))

Expand All @@ -334,7 +286,6 @@ var _ = Describe("UpdateStemcell", func() {
Name: release2Name, Version: release2Version,
RemotePath: newRelease2RemotePath,
RemoteSource: unpublishableReleaseSourceID,
SHA1: "not-calculated",
},
))
})
Expand Down Expand Up @@ -439,7 +390,7 @@ var _ = Describe("UpdateStemcell", func() {
Version: newStemcellVersion,
}))

Expect(updatedLockfile.Releases).To(HaveLen(3))
Expect(updatedLockfile.Releases).To(HaveLen(2))
Expect(updatedLockfile.Releases).To(ContainElement(
cargo.BOSHReleaseTarballLock{
Name: release1Name,
Expand All @@ -458,15 +409,6 @@ var _ = Describe("UpdateStemcell", func() {
RemotePath: newRelease2RemotePath,
},
))
Expect(updatedLockfile.Releases).To(ContainElement(
cargo.BOSHReleaseTarballLock{
Name: release3Name,
Version: release3Version,
SHA1: newRelease3SHA,
RemoteSource: publishableReleaseSourceID,
RemotePath: newRelease3RemotePath,
},
))
})
})

Expand Down

0 comments on commit b42a5ce

Please sign in to comment.