This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
B&R
committed
Jan 14, 2023
1 parent
da1a601
commit 9e96b96
Showing
1 changed file
with
1 addition
and
28 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 |
---|---|---|
|
@@ -44,34 +44,7 @@ func TestRenderTemplate_WithValidParams(t *testing.T) { | |
// will contain: | ||
// - plaintext value like 'riotkit' as user | ||
// - not processed '${DB_PASSWORD}' as password | ||
assert.Contains(t, out, "pgbr db backup --password '${DB_PASSWORD}' --user 'riotkit' --db-name 'rkc-test' --port '5432'") | ||
assert.Contains(t, out, "pgbr db backup --password '${DB_PASSWORD}' --user 'riotkit' --port '5432' --host 'postgres.db.svc.cluster.local'") | ||
assert.Contains(t, out, "exec backup-maker make") // the last command is backup-maker (may change within the template, just like line above) | ||
assert.Nil(t, err) | ||
} | ||
|
||
func TestRenderTemplate_FailsWhenAnyVariableIsMissing(t *testing.T) { | ||
params := map[string]string{ | ||
"hostname": "postgres.db.svc.cluster.local", | ||
"port": "5432", | ||
// NOTICE: a few variables there are missing: db, user, password | ||
} | ||
|
||
repository := map[string]string{ | ||
"url": "https://example.org", | ||
"token": "${BR_TOKEN}", | ||
"encryptionKeyPath": "/var/lib/backup-repository/encryption.key", | ||
"passphrase": "${GPG_PASSPHRASE}", | ||
"recipient": "[email protected]", | ||
"collectionId": "111-222-333-444", | ||
} | ||
|
||
template := generate.Templating{} | ||
_, err := template.RenderTemplate("pg15", "backup", map[string]interface{}{ | ||
"Params": params, | ||
"Repository": repository, | ||
}) | ||
|
||
assert.NotNil(t, err) | ||
assert.Contains(t, err.Error(), "pg15") | ||
assert.Contains(t, err.Error(), "map has no entry for key") | ||
} |