add additional integration tests

This commit is contained in:
pascal
2026-04-20 17:24:04 +02:00
parent 470307079b
commit a4b55af99c
12 changed files with 1975 additions and 2 deletions

View File

@@ -8,6 +8,8 @@ import (
"gorm.io/gorm"
nbdns "github.com/netbirdio/netbird/dns"
"github.com/netbirdio/netbird/management/internals/modules/zones"
"github.com/netbirdio/netbird/management/internals/modules/zones/records"
resourceTypes "github.com/netbirdio/netbird/management/server/networks/resources/types"
routerTypes "github.com/netbirdio/netbird/management/server/networks/routers/types"
networkTypes "github.com/netbirdio/netbird/management/server/networks/types"
@@ -238,3 +240,37 @@ func VerifyPostureCheckNotInDB(t *testing.T, db *gorm.DB, postureCheckID string)
db.Model(&posture.Checks{}).Where("id = ? AND account_id = ?", postureCheckID, TestAccountId).Count(&count)
assert.Equal(t, int64(0), count, "Expected posture check %s to NOT exist in DB", postureCheckID)
}
// VerifyZoneInDB reads a zone directly from the DB and returns it.
func VerifyZoneInDB(t *testing.T, db *gorm.DB, zoneID string) *zones.Zone {
t.Helper()
var zone zones.Zone
err := db.Where("id = ? AND account_id = ?", zoneID, TestAccountId).First(&zone).Error
require.NoError(t, err, "Expected zone %s to exist in DB", zoneID)
return &zone
}
// VerifyZoneNotInDB verifies that a zone does not exist in the DB.
func VerifyZoneNotInDB(t *testing.T, db *gorm.DB, zoneID string) {
t.Helper()
var count int64
db.Model(&zones.Zone{}).Where("id = ? AND account_id = ?", zoneID, TestAccountId).Count(&count)
assert.Equal(t, int64(0), count, "Expected zone %s to NOT exist in DB", zoneID)
}
// VerifyRecordInDB reads a record directly from the DB and returns it.
func VerifyRecordInDB(t *testing.T, db *gorm.DB, recordID string) *records.Record {
t.Helper()
var record records.Record
err := db.Where("id = ? AND account_id = ?", recordID, TestAccountId).First(&record).Error
require.NoError(t, err, "Expected record %s to exist in DB", recordID)
return &record
}
// VerifyRecordNotInDB verifies that a record does not exist in the DB.
func VerifyRecordNotInDB(t *testing.T, db *gorm.DB, recordID string) {
t.Helper()
var count int64
db.Model(&records.Record{}).Where("id = ? AND account_id = ?", recordID, TestAccountId).Count(&count)
assert.Equal(t, int64(0), count, "Expected record %s to NOT exist in DB", recordID)
}