atc: permanent unique version history for base types

Signed-off-by: Clara Fu <cfu@pivotal.io>
This commit is contained in:
Clara Fu 2019-02-13 15:15:45 -05:00
parent 5061fd2899
commit 41b2ef37d8
3 changed files with 28 additions and 5 deletions

View File

@ -73,7 +73,7 @@ func (brt BaseResourceType) create(tx Tx, unique bool) (*UsedBaseResourceType, e
Suffix(`
ON CONFLICT (name) DO UPDATE SET
name = EXCLUDED.name,
unique_version_history = EXCLUDED.unique_version_history
unique_version_history = EXCLUDED.unique_version_history OR base_resource_types.unique_version_history
RETURNING id, unique_version_history
`).
RunWith(tx).

View File

@ -56,23 +56,46 @@ var _ = Describe("WorkerResourceType", func() {
})
Context("when the base resource type becomes unique", func() {
var uniqueUsedWorkerResourceType *db.UsedWorkerResourceType
BeforeEach(func() {
unique = true
})
It("creates the base resource type with unique history", func() {
tx, err := dbConn.Begin()
Expect(err).ToNot(HaveOccurred())
uniqueUsedWorkerResourceType, err := wrt.FindOrCreate(tx, unique)
uniqueUsedWorkerResourceType, err = wrt.FindOrCreate(tx, unique)
Expect(err).ToNot(HaveOccurred())
err = tx.Commit()
Expect(err).ToNot(HaveOccurred())
})
It("creates the base resource type with unique history", func() {
Expect(uniqueUsedWorkerResourceType).ToNot(Equal(usedWorkerResourceType))
Expect(uniqueUsedWorkerResourceType.UsedBaseResourceType.UniqueVersionHistory).To(BeTrue())
})
Context("when the base resource type is saved again as not unique", func() {
var anotherUniqueUWRT *db.UsedWorkerResourceType
BeforeEach(func() {
unique = false
tx, err := dbConn.Begin()
Expect(err).ToNot(HaveOccurred())
anotherUniqueUWRT, err = wrt.FindOrCreate(tx, unique)
Expect(err).ToNot(HaveOccurred())
err = tx.Commit()
Expect(err).ToNot(HaveOccurred())
})
It("stays as unique history", func() {
Expect(anotherUniqueUWRT.UsedBaseResourceType.UniqueVersionHistory).To(BeTrue())
})
})
})
})
})

View File

@ -11,4 +11,4 @@ var Version = "0.0.0-dev"
//
// New features that are otherwise backwards-compatible should result in a
// minor version bump.
var WorkerVersion = "2.2"
var WorkerVersion = "2.1"