argo-cd/test/e2e/git_submodule_test.go
Yann Soubeyrand 41e91d5acd
fix(repo-server): completely clean up Git working directory (#3683) (#13001)
* refactor(util/git/client): make runCredentialedCmd() signature coherent with runCmd() one

Signed-off-by: Yann Soubeyrand <yann.soubeyrand@camptocamp.com>

* fix(repo-server): completely clean up Git working directory

In some cases, for example when a Git submodule wasn’t present anymore
in a Git revision, the repo-server didn’t completely clean up its Git
working directory.

Fixes #3683

Signed-off-by: Yann Soubeyrand <yann.soubeyrand@camptocamp.com>

---------

Signed-off-by: Yann Soubeyrand <yann.soubeyrand@camptocamp.com>
2023-05-27 15:57:59 -04:00

64 lines
1.6 KiB
Go

package e2e
import (
"testing"
v1 "k8s.io/api/core/v1"
"github.com/argoproj/argo-cd/v2/test/e2e/fixture"
. "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
. "github.com/argoproj/argo-cd/v2/test/e2e/fixture/app"
)
func TestGitSubmoduleSSHSupport(t *testing.T) {
Given(t).
RepoURLType(fixture.RepoURLTypeSSHSubmoduleParent).
Path("submodule").
Recurse().
CustomSSHKnownHostsAdded().
SubmoduleSSHRepoURLAdded(true).
When().
CreateFromFile(func(app *Application) {}).
Sync().
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(Pod(func(p v1.Pod) bool { return p.Name == "pod-in-submodule" }))
}
func TestGitSubmoduleHTTPSSupport(t *testing.T) {
Given(t).
RepoURLType(fixture.RepoURLTypeHTTPSSubmoduleParent).
Path("submodule").
Recurse().
CustomCACertAdded().
SubmoduleHTTPSRepoURLAdded(true).
When().
CreateFromFile(func(app *Application) {}).
Sync().
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(Pod(func(p v1.Pod) bool { return p.Name == "pod-in-submodule" }))
}
func TestGitSubmoduleRemovalSupport(t *testing.T) {
Given(t).
RepoURLType(fixture.RepoURLTypeSSHSubmoduleParent).
Path("submodule").
Recurse().
CustomSSHKnownHostsAdded().
SubmoduleSSHRepoURLAdded(true).
When().
CreateFromFile(func(app *Application) {}).
Sync().
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(Pod(func(p v1.Pod) bool { return p.Name == "pod-in-submodule" })).
When().
RemoveSubmodule().
Refresh(RefreshTypeNormal).
Sync().
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(NotPod(func(p v1.Pod) bool { return p.Name == "pod-in-submodule" }))
}