gitrepo: reconcileInclude test assertion fixes
Use the created artifact server test storage in reconcileInclude test's GitRepositoryReconciler and cleanup the created storage. Fix the test assertions to check the copied artifact directories in the correct path. Also, update the tests to expect artifacts in the include `toPath` to exist. Signed-off-by: Sunny <darkowlzz@protonmail.com>
This commit is contained in:
parent
c2e6875284
commit
7e71185594
|
@ -788,7 +788,7 @@ func TestGitRepositoryReconciler_reconcileInclude(t *testing.T) {
|
||||||
g.Expect(err).NotTo(HaveOccurred())
|
g.Expect(err).NotTo(HaveOccurred())
|
||||||
storage, err := newTestStorage(server.HTTPServer)
|
storage, err := newTestStorage(server.HTTPServer)
|
||||||
g.Expect(err).NotTo(HaveOccurred())
|
g.Expect(err).NotTo(HaveOccurred())
|
||||||
defer os.RemoveAll(testStorage.BasePath)
|
defer os.RemoveAll(storage.BasePath)
|
||||||
|
|
||||||
dependencyInterval := 5 * time.Second
|
dependencyInterval := 5 * time.Second
|
||||||
|
|
||||||
|
@ -833,8 +833,8 @@ func TestGitRepositoryReconciler_reconcileInclude(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
includes: []include{
|
includes: []include{
|
||||||
{name: "a", toPath: "a/"},
|
{name: "a", toPath: "a/", shouldExist: true},
|
||||||
{name: "b", toPath: "b/"},
|
{name: "b", toPath: "b/", shouldExist: true},
|
||||||
},
|
},
|
||||||
want: ctrl.Result{RequeueAfter: interval},
|
want: ctrl.Result{RequeueAfter: interval},
|
||||||
assertConditions: []metav1.Condition{
|
assertConditions: []metav1.Condition{
|
||||||
|
@ -970,7 +970,7 @@ func TestGitRepositoryReconciler_reconcileInclude(t *testing.T) {
|
||||||
g.Expect(got).To(Equal(tt.want))
|
g.Expect(got).To(Equal(tt.want))
|
||||||
for _, i := range tt.includes {
|
for _, i := range tt.includes {
|
||||||
if i.toPath != "" {
|
if i.toPath != "" {
|
||||||
expect := g.Expect(filepath.Join(testStorage.BasePath, i.toPath))
|
expect := g.Expect(filepath.Join(tmpDir, i.toPath))
|
||||||
if i.shouldExist {
|
if i.shouldExist {
|
||||||
expect.To(BeADirectory())
|
expect.To(BeADirectory())
|
||||||
} else {
|
} else {
|
||||||
|
@ -978,9 +978,9 @@ func TestGitRepositoryReconciler_reconcileInclude(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if i.shouldExist {
|
if i.shouldExist {
|
||||||
g.Expect(filepath.Join(testStorage.BasePath, i.toPath)).Should(BeADirectory())
|
g.Expect(filepath.Join(tmpDir, i.toPath)).Should(BeADirectory())
|
||||||
} else {
|
} else {
|
||||||
g.Expect(filepath.Join(testStorage.BasePath, i.toPath)).ShouldNot(BeADirectory())
|
g.Expect(filepath.Join(tmpDir, i.toPath)).ShouldNot(BeADirectory())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue