Skip to content

Commit

Permalink
Added unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Sethiya <[email protected]>
  • Loading branch information
sethiyash committed Apr 1, 2024
1 parent 12f54f6 commit 1283331
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion test/e2e/change_rule_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 VMware, Inc.
// Copyright 2024 The Carvel Authors.
// SPDX-License-Identifier: Apache-2.0

package e2e
Expand Down

0 comments on commit 1283331

Please sign in to comment.