Test further commits to push branch

This adds a test to check that should there be a further update to
make, another commit is pushed to the "push branch". In this case, the
image policy gets a new latest image.

The test fails at present because the controller is not watching image
policies (and will not run again on the long interval specified).

Signed-off-by: Michael Bridgen <michael@weave.works>
This commit is contained in:
Michael Bridgen 2021-04-02 19:45:37 +01:00
parent 89733c608e
commit cc3bd7e1da
1 changed files with 16 additions and 1 deletions

View File

@ -564,7 +564,6 @@ Images:
)
const latestImage = "helloworld:1.0.1"
const evenLatestImage = "helloworld:1.2.0"
BeforeEach(func() {
cloneLocalRepoURL = gitServer.HTTPAddressWithCredentials() + repositoryPath
@ -726,6 +725,22 @@ Images:
Expect(commit.Message).To(Equal(commitMessage))
})
It("pushes another commit to the existing push branch", func() {
// observe the first commit
waitForNewHead(localRepo, pushBranch)
head, err := localRepo.Reference(plumbing.NewRemoteReferenceName(originRemote, pushBranch), true)
headHash := head.String()
Expect(err).NotTo(HaveOccurred())
// update the policy and expect another commit in the push branch
policy.Status.LatestImage = "helloworld:v1.3.0"
Expect(k8sClient.Status().Update(context.TODO(), policy)).To(Succeed())
waitForNewHead(localRepo, pushBranch)
head, err = localRepo.Reference(plumbing.NewRemoteReferenceName(originRemote, pushBranch), true)
Expect(err).NotTo(HaveOccurred())
Expect(head.String()).NotTo(Equal(headHash))
})
AfterEach(func() {
Expect(k8sClient.Delete(context.Background(), update)).To(Succeed())
})