Skip to content

Commit

Permalink
fix for the testcase printTreeViewDetailed
Browse files Browse the repository at this point in the history
Signed-off-by: schakrad <58915923+schakrad@users.noreply.github.com>
  • Loading branch information
schakrad committed Sep 10, 2023
1 parent d4878ca commit 7819110
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/mattn/go-isatty"
"io"
"os"
"reflect"
Expand All @@ -15,6 +14,8 @@ import (
"time"
"unicode/utf8"

"github.com/mattn/go-isatty"

"github.com/argoproj/gitops-engine/pkg/health"
"github.com/argoproj/gitops-engine/pkg/sync/common"
"github.com/argoproj/gitops-engine/pkg/sync/hook"
Expand Down Expand Up @@ -1591,7 +1592,7 @@ func printTreeViewDetailed(nodeMapping map[string]argoappv1.ResourceNode, parent
tbl := tableConfig()
tbl.AddRow("GROUP", "NAMESPACE", "KIND", "NAME", "STATUS", "HEALTH", "HOOK", "MESSAGE", "RESOURCE STATUS", "REASON", "AGE")
for uid := range parentNodes {
treeViewAppGetDetailed("", tbl, nodeMapping, parentChildMapping, nodeMapping[uid], mapNodeNameToResourceState)
detailedTreeViewAppGet("", tbl, nodeMapping, parentChildMapping, nodeMapping[uid], mapNodeNameToResourceState)
}
fmt.Fprintln(w, tbl)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/argocd/commands/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ func TestFindRevisionHistoryWithoutPassedId(t *testing.T) {
func TestPrintTreeViewDetailed(t *testing.T) {
var nodes [3]v1alpha1.ResourceNode
nodes[0].ResourceRef = v1alpha1.ResourceRef{Group: "", Version: "v1", Kind: "Pod", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo-5dcd5457d5-6trpt", UID: "92c3a5fe-d13e-4ae2-b8ec-c10dd3543b28"}
nodes[0].Health.Status = "Degraded"
nodes[0].Health.Message = "Readiness Gate failed"
nodes[0].Health = &v1alpha1.HealthStatus{Status: "Degraded", Message: "Readiness Gate failed"}
nodes[0].ParentRefs = []v1alpha1.ResourceRef{{Group: "apps", Version: "v1", Kind: "ReplicaSet", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo-5dcd5457d5", UID: "75c30dce-1b66-414f-a86c-573a74be0f40"}}
nodes[1].ResourceRef = v1alpha1.ResourceRef{Group: "apps", Version: "v1", Kind: "ReplicaSet", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo-5dcd5457d5", UID: "75c30dce-1b66-414f-a86c-573a74be0f40"}
nodes[1].ParentRefs = []v1alpha1.ResourceRef{{Group: "argoproj.io", Version: "", Kind: "Rollout", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo", UID: "87f3aab0-f634-4b2c-959a-7ddd30675ed0"}}
Expand Down
4 changes: 2 additions & 2 deletions cmd/argocd/commands/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func extractHealthStatusAndReason(node v1alpha1.ResourceNode) (healthStatus heal
return
}

func treeViewAppGetDetailed(prefix string, tbl *uitable.Table, objs map[string]v1alpha1.ResourceNode, obj map[string][]string, parent v1alpha1.ResourceNode, mapNodeNameToResourceState map[string]*resourceState) {
func detailedTreeViewAppGet(prefix string, tbl *uitable.Table, objs map[string]v1alpha1.ResourceNode, obj map[string][]string, parent v1alpha1.ResourceNode, mapNodeNameToResourceState map[string]*resourceState) {
healthStatus, reason := extractHealthStatusAndReason(parent)

var readyColor *color.Color
Expand Down Expand Up @@ -89,7 +89,7 @@ func treeViewAppGetDetailed(prefix string, tbl *uitable.Table, objs map[string]v
default:
p = prefix + firstElemPrefix
}
treeViewAppGetDetailed(p, tbl, objs, obj, objs[child], mapNodeNameToResourceState)
detailedTreeViewAppGet(p, tbl, objs, obj, objs[child], mapNodeNameToResourceState)
}

}
Expand Down
6 changes: 4 additions & 2 deletions cmd/argocd/commands/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestTreeViewAppGetDetailed(t *testing.T) {
var child v1alpha1.ResourceNode
child.ResourceRef = v1alpha1.ResourceRef{Group: "apps", Version: "v1", Kind: "ReplicaSet", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo-5dcd5457d5", UID: "75c30dce-1b66-414f-a86c-573a74be0f40"}
child.ParentRefs = []v1alpha1.ResourceRef{{Group: "argoproj.io", Version: "", Kind: "Rollout", Namespace: "sandbox-rollout-numalogic-demo", Name: "numalogic-rollout-demo", UID: "87f3aab0-f634-4b2c-959a-7ddd30675ed0"}}

child.Health = &v1alpha1.HealthStatus{Status: "Degraded", Message: "Readiness Gate failed"}
objs["75c30dce-1b66-414f-a86c-573a74be0f40"] = child

childMapping := make(map[string][]string)
Expand All @@ -35,7 +35,7 @@ func TestTreeViewAppGetDetailed(t *testing.T) {

tbl := uitable.New()

treeViewAppGetDetailed("", tbl, objs, childMapping, parent, stateMap)
detailedTreeViewAppGet("", tbl, objs, childMapping, parent, stateMap)

output := tbl.String()

Expand All @@ -45,6 +45,8 @@ func TestTreeViewAppGetDetailed(t *testing.T) {
assert.Contains(t, output, "Healthy")
assert.Contains(t, output, "No Issues")
assert.Contains(t, output, "argoproj.io")
assert.Contains(t, output, "Degraded")
assert.Contains(t, output, "Readiness Gate failed")
}

func TestPrintPrefix(t *testing.T) {
Expand Down

0 comments on commit 7819110

Please sign in to comment.