test(middleware): add unit tests for middleware behavior
SonarQube Scan / SonarQube Trigger (push) Successful in 1m30s
SonarQube Scan / SonarQube Trigger (push) Successful in 1m30s
- remove redundant check on registry.Update and check if slug exist before locking the mutex - Update SonarQube action to not use Go cache when setting up Go
This commit is contained in:
@@ -94,12 +94,13 @@ func (r *registry) Update(user string, oldKey, newKey Key) error {
|
||||
return ErrInvalidSlug
|
||||
}
|
||||
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if _, exists := r.slugIndex[newKey]; exists && newKey != oldKey {
|
||||
return ErrSlugInUse
|
||||
}
|
||||
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
client, ok := r.byUser[user][oldKey]
|
||||
if !ok {
|
||||
return ErrSessionNotFound
|
||||
@@ -111,9 +112,6 @@ func (r *registry) Update(user string, oldKey, newKey Key) error {
|
||||
client.Slug().Set(newKey.Id)
|
||||
r.slugIndex[newKey] = user
|
||||
|
||||
if r.byUser[user] == nil {
|
||||
r.byUser[user] = make(map[Key]Session)
|
||||
}
|
||||
r.byUser[user][newKey] = client
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user