fix(netbox/test): test custom fields first (#7104)

More atomic and it makes more sense for users to check that the Netbox
configuration is correct before doing any write operations
This commit is contained in:
Pierre Donias 2023-10-18 11:56:10 +02:00 committed by GitHub
parent a3b8553cec
commit 9b236a6191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -41,6 +41,7 @@
- @xen-orchestra/xapi minor - @xen-orchestra/xapi minor
- xo-server minor - xo-server minor
- xo-server-backup-reports minor - xo-server-backup-reports minor
- xo-server-netbox patch
- xo-server-usage-report patch - xo-server-usage-report patch
- xo-web minor - xo-web minor

View File

@ -103,6 +103,8 @@ class Netbox {
} }
async test() { async test() {
await this.#checkCustomFields()
const randomSuffix = Math.random().toString(36).slice(2, 11) const randomSuffix = Math.random().toString(36).slice(2, 11)
const name = '[TMP] Xen Orchestra Netbox plugin test - ' + randomSuffix const name = '[TMP] Xen Orchestra Netbox plugin test - ' + randomSuffix
await this.#request('/virtualization/cluster-types/', 'POST', { await this.#request('/virtualization/cluster-types/', 'POST', {
@ -113,8 +115,6 @@ class Netbox {
}) })
const nbClusterTypes = await this.#request(`/virtualization/cluster-types/?name=${encodeURIComponent(name)}`) const nbClusterTypes = await this.#request(`/virtualization/cluster-types/?name=${encodeURIComponent(name)}`)
await this.#checkCustomFields()
if (nbClusterTypes.length !== 1) { if (nbClusterTypes.length !== 1) {
throw new Error('Could not properly write and read Netbox') throw new Error('Could not properly write and read Netbox')
} }