-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add unit tests for tarianctl install
- Loading branch information
1 parent
b55b990
commit fee9bd4
Showing
9 changed files
with
382 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package install | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestNatsHelmDefaultValues(t *testing.T) { | ||
natsValuesFile := "nats_values_test.yaml" | ||
|
||
defer func() { | ||
if err := os.Remove(natsValuesFile); err != nil { | ||
t.Errorf("Failed to remove temporary file: %v", err) | ||
} | ||
}() | ||
|
||
err := natsHelmDefaultValues(natsValuesFile) | ||
if err != nil { | ||
t.Errorf("natsHelmDefaultValues failed: %v", err) | ||
} | ||
|
||
yamlContent, err := os.ReadFile(natsValuesFile) | ||
if err != nil { | ||
t.Errorf("Failed to read the temporary file: %v", err) | ||
} | ||
|
||
if !containsSubstring(string(yamlContent), "nats:alpine") { | ||
t.Errorf("natsValuesFile does not contain 'nats:alpine'") | ||
} | ||
|
||
if !containsSubstring(string(yamlContent), "enabled: true") { | ||
t.Errorf("natsValuesFile does not contain 'enabled: true' in Jetstream") | ||
} | ||
|
||
if !containsSubstring(string(yamlContent), "size: 128Mi") { | ||
t.Errorf("natsValuesFile does not contain 'size: 128Mi' in MemStorage") | ||
} | ||
|
||
if !containsSubstring(string(yamlContent), "size: 50Mi") { | ||
t.Errorf("natsValuesFile does not contain 'size: 50Mi' in FileStorage") | ||
} | ||
} | ||
|
||
func TestDgraphHelmDefaultValues(t *testing.T) { | ||
dgraphValuesFile := "dgraph_values_test.yaml" | ||
|
||
defer func() { | ||
if err := os.Remove(dgraphValuesFile); err != nil { | ||
t.Errorf("Failed to remove temporary file: %v", err) | ||
} | ||
}() | ||
|
||
err := dgraphHelmDefaultValues(dgraphValuesFile) | ||
if err != nil { | ||
t.Errorf("dgraphHelmDefaultValues failed: %v", err) | ||
} | ||
|
||
yamlContent, err := os.ReadFile(dgraphValuesFile) | ||
if err != nil { | ||
t.Errorf("Failed to read the temporary file: %v", err) | ||
} | ||
|
||
if !containsSubstring(string(yamlContent), "DGRAPH_ALPHA_SECURITY") { | ||
t.Errorf("dgraphValuesFile does not contain 'DGRAPH_ALPHA_SECURITY'") | ||
} | ||
|
||
if !containsSubstring(string(yamlContent), "value: whitelist=0.0.0.0/0") { | ||
t.Errorf("dgraphValuesFile does not contain 'value: whitelist=0.0.0.0/0' in ExtraEnvs") | ||
} | ||
} | ||
|
||
func containsSubstring(s, substr string) bool { | ||
return strings.Contains(s, substr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.