Skip to content

Commit

Permalink
Added unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Sethiya <yashsethiya97@gmail.com>
  • Loading branch information
sethiyash committed Apr 1, 2024
1 parent 12f54f6 commit 212e27b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/kapp/diffgraph/change_graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,33 @@ metadata:
require.Equal(t, expectedOutput, output)
}

func TestChangeGraphWithSecretAndSA(t *testing.T) {
yaml := `
apiVersion: v1
kind: ServiceAccount
metadata:
name: sa-0
---
apiVersion: v1
kind: Secret
metadata:
name: secret-0
annotations:
kubernetes.io/service-account.name: sa-0
type: kubernetes.io/service-account-token
`

graph, err := buildChangeGraph(yaml, ctldgraph.ActualChangeOpUpsert, t)
require.NoErrorf(t, err, "Expected graph to build")

output := strings.TrimSpace(graph.PrintStr())
expectedOutput := strings.TrimSpace(`
(upsert) serviceaccount/sa-0 (v1) cluster
(upsert) secret/secret-0 (v1) cluster
`)
require.Equal(t, expectedOutput, output)
}

func buildChangeGraph(resourcesBs string, op ctldgraph.ActualChangeOp, t *testing.T) (*ctldgraph.ChangeGraph, error) {
return buildChangeGraphWithOpts(buildGraphOpts{resourcesBs: resourcesBs, op: op}, t)
}
Expand Down

0 comments on commit 212e27b

Please sign in to comment.