Rearrange the protocol x implementation tests
There is a core chuck of testing that is repeated for {SSH,HTTP} x {go-git,libgit2}, which is done by repeating a func value in different contexts. Instead of mutating variables in the func's closure, it's a bit clearer (and shorter) to pass them to a higher-order func. Signed-off-by: Michael Bridgen <michael@weave.works>
This commit is contained in:
parent
9c375c582d
commit
8daa6491a3
|
@ -111,15 +111,8 @@ var _ = Describe("ImageUpdateAutomation", func() {
|
||||||
Expect(initGitRepo(gitServer, "testdata/appconfig", branch, repositoryPath)).To(Succeed())
|
Expect(initGitRepo(gitServer, "testdata/appconfig", branch, repositoryPath)).To(Succeed())
|
||||||
})
|
})
|
||||||
|
|
||||||
// These are used for end-to-end tests; withImagePolicy is
|
endToEnd := func(impl, proto string) func() {
|
||||||
// effectively parameterised on these two values.
|
return func() {
|
||||||
var (
|
|
||||||
// set the proto and impl in BeforeEach
|
|
||||||
proto string
|
|
||||||
impl string
|
|
||||||
)
|
|
||||||
|
|
||||||
withImagePolicy := func() {
|
|
||||||
var (
|
var (
|
||||||
// for cloning locally
|
// for cloning locally
|
||||||
cloneLocalRepoURL string
|
cloneLocalRepoURL string
|
||||||
|
@ -357,35 +350,23 @@ var _ = Describe("ImageUpdateAutomation", func() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Context("Using go-git", func() {
|
Context("Using go-git", func() {
|
||||||
BeforeEach(func() { impl = sourcev1.GoGitImplementation })
|
|
||||||
|
|
||||||
Context("with HTTP", func() {
|
Context("with HTTP", func() {
|
||||||
BeforeEach(func() { proto = "http" })
|
Describe("runs end to end", endToEnd(sourcev1.GoGitImplementation, "http"))
|
||||||
Describe("with image policy", withImagePolicy)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("with SSH", func() {
|
Context("with SSH", func() {
|
||||||
BeforeEach(func() { proto = "ssh" })
|
Describe("runs end to end", endToEnd(sourcev1.GoGitImplementation, "ssh"))
|
||||||
Describe("with image policy", withImagePolicy)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("Using libgit2", func() {
|
Context("Using libgit2", func() {
|
||||||
BeforeEach(func() { impl = sourcev1.LibGit2Implementation })
|
|
||||||
|
|
||||||
Context("with HTTP", func() {
|
Context("with HTTP", func() {
|
||||||
BeforeEach(func() { proto = "http" })
|
Describe("runs end to end", endToEnd(sourcev1.LibGit2Implementation, "http"))
|
||||||
Describe("with image policy", withImagePolicy)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Marked "Pending" because the libgit2 SSH implementation
|
|
||||||
// won't work with the gittestserver yet -- see
|
|
||||||
// https://github.com/fluxcd/source-controller/issues/287
|
|
||||||
Context("with SSH", func() {
|
Context("with SSH", func() {
|
||||||
BeforeEach(func() { proto = "ssh" })
|
Describe("runs end to end", endToEnd(sourcev1.LibGit2Implementation, "ssh"))
|
||||||
Describe("with image policy", withImagePolicy)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue