-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add debug to new version #336
Conversation
Mergecat's ReviewClick to read mergecats review!😼 Mergecat review of pkg/affected_apps/argocd_matcher.go@@ -36,7 +36,10 @@ func logCounts(repoApps *appdir.AppDirectory) {
if repoApps == nil {
log.Debug().Msg("found no apps")
} else {
- log.Debug().Msgf("found %d apps", repoApps.Count())
+ log.Debug().Int("apps", repoApps.AppsCount()).
+ Int("app files", repoApps.AppFilesCount()).
+ Int("app dirs", repoApps.AppDirsCount()).
+ Msg("mapped apps")
}
}
Feedback & Suggestions:
Overall, the diff enhances the logging functionality, which is beneficial for debugging and monitoring. Keep up the good work! 🌟 😼 Mergecat review of pkg/appdir/app_directory.go@@ -23,10 +23,18 @@ func NewAppDirectory() *AppDirectory {
}
}
-func (d *AppDirectory) Count() int {
+func (d *AppDirectory) AppsCount() int {
return len(d.appsMap)
}
+func (d *AppDirectory) AppFilesCount() int {
+ return len(d.appFiles)
+}
+
+func (d *AppDirectory) AppDirsCount() int {
+ return len(d.appDirs)
+}
+
func (d *AppDirectory) Union(other *AppDirectory) *AppDirectory {
var join AppDirectory
join.appsMap = mergeMaps(d.appsMap, other.appsMap, takeFirst[v1alpha1.Application]) Feedback & Suggestions:
😼 Mergecat review of pkg/appdir/vcstoargomap_test.go@@ -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.
@@ -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)
}
@@ -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{
@@ -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{ Feedback & Suggestions:
😼 Mergecat review of pkg/app_watcher/app_watcher_test.go@@ -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"},
@@ -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) {
@@ -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 {
@@ -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. Feedback & Suggestions:
Overall, the changes improve the clarity and consistency of the test cases. Keep up the good work! 🌟 Dependency ReviewClick to read mergecats review!No suggestions found |
Oops, wrong repo =/ |
No description provided.