From 45480697c763e1e0f8419f69cca2d13adba3523f Mon Sep 17 00:00:00 2001 From: Hugo Hakim Damer Date: Mon, 11 Mar 2024 03:10:03 +0100 Subject: [PATCH] Fix small test suite issues --- management/server/group_test.go | 16 +++++++++------- management/server/peer_test.go | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/management/server/group_test.go b/management/server/group_test.go index 035fbb564ac..efbfd5c6af4 100644 --- a/management/server/group_test.go +++ b/management/server/group_test.go @@ -161,14 +161,16 @@ func TestDefaultAccountManager_GroupIPv6Consistency(t *testing.T) { require.NotNil(t, account.Peers[peer2Id].IP6, "peer2 should have an IPv6 address as it is a member of the IPv6-enabled group.") // Force disable IPv6. - account.GetPeer(peer1Id).V6Setting = nbpeer.V6Disabled - account.GetPeer(peer2Id).V6Setting = nbpeer.V6Disabled - account.UpdatePeer(account.Peers[peer1Id]) - account.UpdatePeer(account.Peers[peer2Id]) - err = am.Store.SaveAccount(account) - require.NoError(t, err, "unable to update account") + peer1 := account.GetPeer(peer1Id) + peer2 := account.GetPeer(peer2Id) + peer1.V6Setting = nbpeer.V6Disabled + peer2.V6Setting = nbpeer.V6Disabled + _, err = am.UpdatePeer(account.Id, groupAdminUserID, peer1) + require.NoError(t, err, "unable to update peer1") + _, err = am.UpdatePeer(account.Id, groupAdminUserID, peer2) + require.NoError(t, err, "unable to update peer2") account, err = am.Store.GetAccount(account.Id) - require.NoError(t, err, "unable to update account") + require.NoError(t, err, "unable to fetch updated account") group = account.GetGroup("grp-for-ipv6") require.Nil(t, account.GetPeer(peer1Id).IP6, "peer1 should not have an IPv6 address as it is force disabled.") require.Nil(t, account.GetPeer(peer2Id).IP6, "peer2 should not have an IPv6 address as it is force disabled.") diff --git a/management/server/peer_test.go b/management/server/peer_test.go index 6a50378f74a..8ef79bf8736 100644 --- a/management/server/peer_test.go +++ b/management/server/peer_test.go @@ -221,7 +221,7 @@ func TestDefaultAccountManager_DeterminePeerV6(t *testing.T) { _, err = manager.DeterminePeerV6(account, peer1) require.NoError(t, err, "unable to determine effective peer IPv6 status") _, err = manager.DeterminePeerV6(account, peer2) - require.NoError(t, err, "unable to determine effective peer IPv6 status") + require.Error(t, err, "determining peer2 IPv6 address should fail as it is force enabled, but unsupported.") require.NotNil(t, peer1.IP6, "peer1 IPv6 address is nil even though it is force enabled.") require.Nil(t, peer2.IP6, "peer2 IPv6 address is not nil even though it is unsupported.")