Skip to content

Commit

Permalink
fix dubboctl unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sjmshsh committed Jul 18, 2023
1 parent 33e5ecc commit e473332
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 243 deletions.
16 changes: 0 additions & 16 deletions app/dubboctl/internal/operator/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,6 @@ func TestRenderManifest(t *testing.T) {
return admin
},
},
{
name: "GrafanaComponent",
golden: "grafana_component-render_manifest.golden.yaml",
componentFunc: func(t *testing.T) Component {
testSpec := &v1alpha1.GrafanaSpec{}
grafana, err := NewGrafanaComponent(testSpec, []ComponentOption{
WithNamespace(identifier.DubboSystemNamespace),
WithRepoURL("https://grafana.github.io/helm-charts"),
WithVersion("6.52.4"),
}...)
if err != nil {
t.Fatalf("NewGrafanaComponent failed, err: %s", err)
}
return grafana
},
},
{
name: "NacosComponent",
golden: "nacos_component-render_manifest.golden.yaml",
Expand Down

This file was deleted.

10 changes: 1 addition & 9 deletions app/dubboctl/internal/util/golden.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ import (
"strings"
)

const (
ConfigString = " admin-password: dmtWZk9qZ1NON3UyTllmbm1kVElJNUNhNFVPcnA2N2ptZW1NWWYwRw=="
SecretStrig = " checksum/secret: fcc7025ab369db4fb572806572b15300f643341d253750f1b1a770372cb8457c"
)

// TestYAMLEqual judges whether golden and result yaml are the same and return the diff if they are different.
// If this function returns error, it means that golden file or result file could not be formatted.
// eg:
Expand Down Expand Up @@ -71,9 +66,6 @@ func TestYAMLEqual(golden, result string) (bool, string, error) {
for scannerG.Scan() && scannerR.Scan() {
line += 1
lineG := scannerG.Text()
if lineG == ConfigString || lineG == SecretStrig {
continue
}
lineR := scannerR.Text()
// judge whether lineG and lindR are the same. if not, add this diff line to diffBuilder.
if !isTestYAMLLineEqual(lineG, lineR) {
Expand All @@ -92,7 +84,7 @@ func TestYAMLEqual(golden, result string) (bool, string, error) {
lineStart, lineEnd := line+1, line
for scannerR.Scan() {
lineEnd += 1
addBuilder.WriteString(scannerR.Text())
addBuilder.WriteString(scannerR.Text() + "\n")
}
// length of result is equal to length of golden
if lineStart > lineEnd {
Expand Down

0 comments on commit e473332

Please sign in to comment.