mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-25 19:56:46 +00:00
add additional integration tests
This commit is contained in:
@@ -134,7 +134,7 @@ func BuildApiBlackBoxWithDBState(t testing_tools.TB, sqlFile string, expectedPee
|
||||
customZonesManager := zonesManager.NewManager(store, am, "")
|
||||
zoneRecordsManager := recordsManager.NewManager(store, am)
|
||||
|
||||
apiHandler, err := http2.NewAPIHandler(context.Background(), am, networksManager, resourcesManager, routersManager, groupsManager, geoMock, authManagerMock, metrics, validatorMock, proxyController, permissionsManager, peersManager, settingsManager, customZonesManager, zoneRecordsManager, networkMapController, nil, serviceManager, nil, nil, nil, nil)
|
||||
apiHandler, err := http2.NewAPIHandler(context.Background(), am, networksManager, resourcesManager, routersManager, groupsManager, geoMock, authManagerMock, metrics, validatorMock, proxyController, permissionsManager, peersManager, settingsManager, customZonesManager, zoneRecordsManager, networkMapController, nil, serviceManager, &domainManager, accessLogsManager, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create API handler: %v", err)
|
||||
}
|
||||
@@ -263,7 +263,7 @@ func BuildApiBlackBoxWithDBStateAndPeerChannel(t testing_tools.TB, sqlFile strin
|
||||
customZonesManager := zonesManager.NewManager(store, am, "")
|
||||
zoneRecordsManager := recordsManager.NewManager(store, am)
|
||||
|
||||
apiHandler, err := http2.NewAPIHandler(context.Background(), am, networksManager, resourcesManager, routersManager, groupsManager, geoMock, authManagerMock, metrics, validatorMock, proxyController, permissionsManager, peersManager, settingsManager, customZonesManager, zoneRecordsManager, networkMapController, nil, serviceManager, nil, nil, nil, nil)
|
||||
apiHandler, err := http2.NewAPIHandler(context.Background(), am, networksManager, resourcesManager, routersManager, groupsManager, geoMock, authManagerMock, metrics, validatorMock, proxyController, permissionsManager, peersManager, settingsManager, customZonesManager, zoneRecordsManager, networkMapController, nil, serviceManager, &domainManager, accessLogsManager, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create API handler: %v", err)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user