Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4a6ab3

Browse files
committed
dbmem2
1 parent ef3f479 commit f4a6ab3

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

coderd/database/dbmem/dbmem.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ type data struct {
147147
workspaceAgentLogs []database.WorkspaceAgentLog
148148
workspaceAgentLogSources []database.WorkspaceAgentLogSource
149149
workspaceAgentScripts []database.WorkspaceAgentScript
150-
workspaceAgentPortShare []database.WorkspaceAgentPortShare
150+
workspaceAgentPortShares []database.WorkspaceAgentPortShare
151151
workspaceApps []database.WorkspaceApp
152152
workspaceAppStatsLastInsertID int64
153153
workspaceAppStats []database.WorkspaceAppStat
@@ -1012,14 +1012,14 @@ func (q *FakeQuerier) CreateWorkspaceAgentPortShare(_ context.Context, arg datab
10121012
q.mutex.Lock()
10131013
defer q.mutex.Unlock()
10141014

1015-
for _, share := range q.workspaceAgentPortShare {
1015+
for _, share := range q.workspaceAgentPortShares {
10161016
if share.WorkspaceID == arg.WorkspaceID && share.AgentName == arg.AgentName && share.Port == arg.Port {
10171017
return xerrors.New("port share already exists")
10181018
}
10191019
}
10201020

10211021
//nolint:gosimple // I disagree
1022-
q.workspaceAgentPortShare = append(q.workspaceAgentPortShare, database.WorkspaceAgentPortShare{
1022+
q.workspaceAgentPortShares = append(q.workspaceAgentPortShares, database.WorkspaceAgentPortShare{
10231023
WorkspaceID: arg.WorkspaceID,
10241024
AgentName: arg.AgentName,
10251025
Port: arg.Port,
@@ -1353,9 +1353,9 @@ func (q *FakeQuerier) DeleteWorkspaceAgentPortShare(_ context.Context, arg datab
13531353
q.mutex.Lock()
13541354
defer q.mutex.Unlock()
13551355

1356-
for i, share := range q.workspaceAgentPortShare {
1356+
for i, share := range q.workspaceAgentPortShares {
13571357
if share.WorkspaceID == arg.WorkspaceID && share.AgentName == arg.AgentName && share.Port == arg.Port {
1358-
q.workspaceAgentPortShare = append(q.workspaceAgentPortShare[:i], q.workspaceAgentPortShare[i+1:]...)
1358+
q.workspaceAgentPortShares = append(q.workspaceAgentPortShares[:i], q.workspaceAgentPortShares[i+1:]...)
13591359
return nil
13601360
}
13611361
}
@@ -4209,7 +4209,7 @@ func (q *FakeQuerier) GetWorkspaceAgentPortShare(_ context.Context, arg database
42094209
q.mutex.RLock()
42104210
defer q.mutex.RUnlock()
42114211

4212-
for _, share := range q.workspaceAgentPortShare {
4212+
for _, share := range q.workspaceAgentPortShares {
42134213
if share.WorkspaceID == arg.WorkspaceID && share.AgentName == arg.AgentName && share.Port == arg.Port {
42144214
return share, nil
42154215
}
@@ -7072,7 +7072,18 @@ func (q *FakeQuerier) UpdateWorkspaceAgentPortShare(ctx context.Context, arg dat
70727072
return err
70737073
}
70747074

7075-
panic("not implemented")
7075+
q.mutex.Lock()
7076+
defer q.mutex.Unlock()
7077+
7078+
for i, share := range q.workspaceAgentPortShares {
7079+
if share.WorkspaceID == arg.WorkspaceID && share.AgentName == arg.AgentName && share.Port == arg.Port {
7080+
share.ShareLevel = arg.ShareLevel
7081+
q.workspaceAgentPortShares[i] = share
7082+
return nil
7083+
}
7084+
}
7085+
7086+
return sql.ErrNoRows
70767087
}
70777088

70787089
func (q *FakeQuerier) UpdateWorkspaceAgentStartupByID(_ context.Context, arg database.UpdateWorkspaceAgentStartupByIDParams) error {

0 commit comments

Comments
 (0)