mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-09 07:15:15 +02:00
Fix store migration on empty string (#2149)
* Fix store migration on empty string when fetching empty values from the database to check for migration our parser failed to handle null strings preventing the service from start this uses sql.NullString to handle that and check for empty string resulted from null data --------- Co-authored-by: Viktor Liu <17948409+lixmal@users.noreply.github.com>
This commit is contained in:
@ -559,6 +559,7 @@ func TestMigrate(t *testing.T) {
|
||||
rt := &route{
|
||||
Network: prefix,
|
||||
PeerGroups: []string{"group1", "group2"},
|
||||
Route: route2.Route{ID: "route1"},
|
||||
}
|
||||
|
||||
err = store.db.Save(rt).Error
|
||||
@ -569,6 +570,26 @@ func TestMigrate(t *testing.T) {
|
||||
|
||||
err = migrate(store.db)
|
||||
require.NoError(t, err, "Migration should not fail on migrated db")
|
||||
|
||||
err = store.db.Delete(rt).Where("id = ?", "route1").Error
|
||||
require.NoError(t, err, "Failed to delete Gob data")
|
||||
|
||||
prefix = netip.MustParsePrefix("12.0.0.0/24")
|
||||
nRT := &route2.Route{
|
||||
Network: prefix,
|
||||
ID: "route2",
|
||||
Peer: "peer-id",
|
||||
}
|
||||
|
||||
err = store.db.Save(nRT).Error
|
||||
require.NoError(t, err, "Failed to insert json nil slice data")
|
||||
|
||||
err = migrate(store.db)
|
||||
require.NoError(t, err, "Migration should not fail on json nil slice populated db")
|
||||
|
||||
err = migrate(store.db)
|
||||
require.NoError(t, err, "Migration should not fail on migrated db")
|
||||
|
||||
}
|
||||
|
||||
func newSqliteStore(t *testing.T) *SqlStore {
|
||||
|
Reference in New Issue
Block a user