Skip to content

Commit

Permalink
fix func names
Browse files Browse the repository at this point in the history
  • Loading branch information
djeebus committed Dec 19, 2024
1 parent 16bc588 commit 418e5fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
13 changes: 7 additions & 6 deletions pkg/app_watcher/app_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ func TestApplicationUpdated(t *testing.T) {
assert.Equal(t, len(ctrl.vcsToArgoMap.GetMap()), 2)

oldAppDirectory := ctrl.vcsToArgoMap.GetAppsInRepo("https://gitlab.com/test/repo.git")
assert.Equal(t, oldAppDirectory.AppsCount(), 1)

newAppDirectory := ctrl.vcsToArgoMap.GetAppsInRepo("https://gitlab.com/test/repo-3.git")
assert.Equal(t, oldAppDirectory.Count(), 1)
assert.Equal(t, newAppDirectory.Count(), 0)
assert.Equal(t, newAppDirectory.AppsCount(), 0)
//
_, err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications("default").Update(ctx, &v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{Name: "test-app-1", Namespace: "default"},
Expand All @@ -102,8 +103,8 @@ func TestApplicationUpdated(t *testing.T) {
time.Sleep(time.Second * 1)
oldAppDirectory = ctrl.vcsToArgoMap.GetAppsInRepo("https://gitlab.com/test/repo.git")
newAppDirectory = ctrl.vcsToArgoMap.GetAppsInRepo("https://gitlab.com/test/repo-3.git")
assert.Equal(t, oldAppDirectory.Count(), 0)
assert.Equal(t, newAppDirectory.Count(), 1)
assert.Equal(t, oldAppDirectory.AppsCount(), 0)
assert.Equal(t, newAppDirectory.AppsCount(), 1)
}

func TestApplicationDeleted(t *testing.T) {
Expand All @@ -119,7 +120,7 @@ func TestApplicationDeleted(t *testing.T) {
assert.Equal(t, len(ctrl.vcsToArgoMap.GetMap()), 2)

appDirectory := ctrl.vcsToArgoMap.GetAppsInRepo("https://gitlab.com/test/repo.git")
assert.Equal(t, appDirectory.Count(), 1)
assert.Equal(t, appDirectory.AppsCount(), 1)
//
err := ctrl.applicationClientset.ArgoprojV1alpha1().Applications("default").Delete(ctx, "test-app-1", metav1.DeleteOptions{})
if err != nil {
Expand All @@ -128,7 +129,7 @@ func TestApplicationDeleted(t *testing.T) {
time.Sleep(time.Second * 1)

appDirectory = ctrl.vcsToArgoMap.GetAppsInRepo("https://gitlab.com/test/repo.git")
assert.Equal(t, appDirectory.Count(), 0)
assert.Equal(t, appDirectory.AppsCount(), 0)
}

// TestIsGitRepo will test various URLs against the isGitRepo function.
Expand Down
16 changes: 7 additions & 9 deletions pkg/appdir/vcstoargomap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestAddApp(t *testing.T) {
v2a.AddApp(app1)
appDir := v2a.GetAppsInRepo("https://github.com/argoproj/argo-cd.git")

assert.Equal(t, appDir.Count(), 1)
assert.Equal(t, appDir.AppsCount(), 1)
assert.Equal(t, len(appDir.appDirs["test-app-1"]), 1)

// Assertions to verify the behavior here.
Expand All @@ -41,7 +41,7 @@ func TestAddApp(t *testing.T) {
}

v2a.AddApp(app2)
assert.Equal(t, appDir.Count(), 2)
assert.Equal(t, appDir.AppsCount(), 2)
assert.Equal(t, len(appDir.appDirs["test-app-2"]), 1)
}

Expand Down Expand Up @@ -73,27 +73,26 @@ func TestDeleteApp(t *testing.T) {
v2a.AddApp(app2)
appDir := v2a.GetAppsInRepo("https://github.com/argoproj/argo-cd.git")

assert.Equal(t, appDir.Count(), 2)
assert.Equal(t, appDir.AppsCount(), 2)
assert.Equal(t, len(appDir.appDirs["test-app-1"]), 1)
assert.Equal(t, len(appDir.appDirs["test-app-2"]), 1)

v2a.DeleteApp(app2)
assert.Equal(t, appDir.Count(), 1)
assert.Equal(t, appDir.AppsCount(), 1)
assert.Equal(t, len(appDir.appDirs["test-app-2"]), 0)
}

func TestVcsToArgoMap_AddAppSet(t *testing.T) {
type args struct {
app *v1alpha1.ApplicationSet
}
tests := []struct {
tests := map[string]struct {
name string
fields VcsToArgoMap
args args
expectedCount int
}{
{
name: "normal process, expect to get the appset stored in the map",
"normal process, expect to get the appset stored in the map": {
fields: NewVcsToArgoMap("dummyuser"),
args: args{
app: &v1alpha1.ApplicationSet{
Expand All @@ -112,8 +111,7 @@ func TestVcsToArgoMap_AddAppSet(t *testing.T) {
},
expectedCount: 1,
},
{
name: "invalid appset",
"invalid appset": {
fields: NewVcsToArgoMap("vcs-username"),
args: args{
app: &v1alpha1.ApplicationSet{
Expand Down

0 comments on commit 418e5fc

Please sign in to comment.