Skip to content

Commit 79b2191

Browse files
committed
dbmem2
1 parent c4cf067 commit 79b2191

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
@@ -146,7 +146,7 @@ type data struct {
146146
workspaceAgentLogs []database.WorkspaceAgentLog
147147
workspaceAgentLogSources []database.WorkspaceAgentLogSource
148148
workspaceAgentScripts []database.WorkspaceAgentScript
149-
workspaceAgentPortShare []database.WorkspaceAgentPortShare
149+
workspaceAgentPortShares []database.WorkspaceAgentPortShare
150150
workspaceApps []database.WorkspaceApp
151151
workspaceAppStatsLastInsertID int64
152152
workspaceAppStats []database.WorkspaceAppStat
@@ -1011,14 +1011,14 @@ func (q *FakeQuerier) CreateWorkspaceAgentPortShare(_ context.Context, arg datab
10111011
q.mutex.Lock()
10121012
defer q.mutex.Unlock()
10131013

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

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

1355-
for i, share := range q.workspaceAgentPortShare {
1355+
for i, share := range q.workspaceAgentPortShares {
13561356
if share.WorkspaceID == arg.WorkspaceID && share.AgentName == arg.AgentName && share.Port == arg.Port {
1357-
q.workspaceAgentPortShare = append(q.workspaceAgentPortShare[:i], q.workspaceAgentPortShare[i+1:]...)
1357+
q.workspaceAgentPortShares = append(q.workspaceAgentPortShares[:i], q.workspaceAgentPortShares[i+1:]...)
13581358
return nil
13591359
}
13601360
}
@@ -4131,7 +4131,7 @@ func (q *FakeQuerier) GetWorkspaceAgentPortShare(_ context.Context, arg database
41314131
q.mutex.RLock()
41324132
defer q.mutex.RUnlock()
41334133

4134-
for _, share := range q.workspaceAgentPortShare {
4134+
for _, share := range q.workspaceAgentPortShares {
41354135
if share.WorkspaceID == arg.WorkspaceID && share.AgentName == arg.AgentName && share.Port == arg.Port {
41364136
return share, nil
41374137
}
@@ -6993,7 +6993,18 @@ func (q *FakeQuerier) UpdateWorkspaceAgentPortShare(ctx context.Context, arg dat
69936993
return err
69946994
}
69956995

6996-
panic("not implemented")
6996+
q.mutex.Lock()
6997+
defer q.mutex.Unlock()
6998+
6999+
for i, share := range q.workspaceAgentPortShares {
7000+
if share.WorkspaceID == arg.WorkspaceID && share.AgentName == arg.AgentName && share.Port == arg.Port {
7001+
share.ShareLevel = arg.ShareLevel
7002+
q.workspaceAgentPortShares[i] = share
7003+
return nil
7004+
}
7005+
}
7006+
7007+
return sql.ErrNoRows
69977008
}
69987009

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

0 commit comments

Comments
 (0)