mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-15 11:22:49 +03:00
Merge: - clients: fix rename
Close #1340 Squashed commit of the following: commit 95f0291c681f98c29f4014b651c159d387301af4 Author: Simon Zolin <s.zolin@adguard.com> Date: Thu Jan 9 18:56:23 2020 +0300 add test commit 293be277e245ff2f430e8c1e9ee3e82dc7da0995 Author: Simon Zolin <s.zolin@adguard.com> Date: Thu Jan 9 16:04:36 2020 +0300 - clients: fix rename
This commit is contained in:
parent
84b11ff7a5
commit
0cd25cf598
@ -468,12 +468,16 @@ func (clients *clientsContainer) Update(name string, c Client) error {
|
||||
|
||||
// update Name index
|
||||
if old.Name != c.Name {
|
||||
delete(clients.list, old.Name)
|
||||
clients.list[c.Name] = old
|
||||
}
|
||||
|
||||
// update upstreams cache
|
||||
delete(clients.upstreamsCache, name)
|
||||
if old.Name != c.Name {
|
||||
delete(clients.upstreamsCache, old.Name)
|
||||
} else {
|
||||
delete(clients.upstreamsCache, c.Name)
|
||||
}
|
||||
|
||||
*old = c
|
||||
return nil
|
||||
|
@ -114,6 +114,7 @@ func TestClients(t *testing.T) {
|
||||
c = Client{}
|
||||
c, b = clients.Find("1.1.1.2")
|
||||
assert.True(t, b && c.Name == "client1-renamed" && c.IDs[0] == "1.1.1.2" && c.UseOwnSettings)
|
||||
assert.True(t, clients.list["client1"] == nil)
|
||||
|
||||
// failed remove - no such name
|
||||
if clients.Del("client3") {
|
||||
|
Loading…
Reference in New Issue
Block a user