Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
B&R committed Jan 14, 2023
1 parent da1a601 commit 9e96b96
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions generate/templating_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit 9e96b96

Please sign in to comment.