66 "sort"
77 "strings"
88 "sync"
9+ "time"
910
1011 "github.com/google/uuid"
1112 "golang.org/x/exp/slices"
@@ -1189,7 +1190,7 @@ func (q *fakeQuerier) InsertTemplateVersion(_ context.Context, arg database.Inse
11891190 CreatedAt : arg .CreatedAt ,
11901191 UpdatedAt : arg .UpdatedAt ,
11911192 Name : arg .Name ,
1192- Description : arg .Description ,
1193+ Readme : arg .Readme ,
11931194 JobID : arg .JobID ,
11941195 }
11951196 q .templateVersions = append (q .templateVersions , version )
@@ -1478,7 +1479,7 @@ func (q *fakeQuerier) UpdateTemplateActiveVersionByID(_ context.Context, arg dat
14781479 defer q .mutex .Unlock ()
14791480
14801481 for index , template := range q .templates {
1481- if template .ID . String () != arg .ID . String () {
1482+ if template .ID != arg .ID {
14821483 continue
14831484 }
14841485 template .ActiveVersionID = arg .ActiveVersionID
@@ -1493,7 +1494,7 @@ func (q *fakeQuerier) UpdateTemplateDeletedByID(_ context.Context, arg database.
14931494 defer q .mutex .Unlock ()
14941495
14951496 for index , template := range q .templates {
1496- if template .ID . String () != arg .ID . String () {
1497+ if template .ID != arg .ID {
14971498 continue
14981499 }
14991500 template .Deleted = arg .Deleted
@@ -1508,7 +1509,7 @@ func (q *fakeQuerier) UpdateTemplateVersionByID(_ context.Context, arg database.
15081509 defer q .mutex .Unlock ()
15091510
15101511 for index , templateVersion := range q .templateVersions {
1511- if templateVersion .ID . String () != arg .ID . String () {
1512+ if templateVersion .ID != arg .ID {
15121513 continue
15131514 }
15141515 templateVersion .TemplateID = arg .TemplateID
@@ -1519,12 +1520,28 @@ func (q *fakeQuerier) UpdateTemplateVersionByID(_ context.Context, arg database.
15191520 return sql .ErrNoRows
15201521}
15211522
1523+ func (q * fakeQuerier ) UpdateTemplateVersionDescriptionByJobID (_ context.Context , arg database.UpdateTemplateVersionDescriptionByJobIDParams ) error {
1524+ q .mutex .Lock ()
1525+ defer q .mutex .Unlock ()
1526+
1527+ for index , templateVersion := range q .templateVersions {
1528+ if templateVersion .JobID != arg .JobID {
1529+ continue
1530+ }
1531+ templateVersion .Readme = arg .Readme
1532+ templateVersion .UpdatedAt = time .Now ()
1533+ q .templateVersions [index ] = templateVersion
1534+ return nil
1535+ }
1536+ return sql .ErrNoRows
1537+ }
1538+
15221539func (q * fakeQuerier ) UpdateProvisionerDaemonByID (_ context.Context , arg database.UpdateProvisionerDaemonByIDParams ) error {
15231540 q .mutex .Lock ()
15241541 defer q .mutex .Unlock ()
15251542
15261543 for index , daemon := range q .provisionerDaemons {
1527- if arg .ID . String () != daemon .ID . String () {
1544+ if arg .ID != daemon .ID {
15281545 continue
15291546 }
15301547 daemon .UpdatedAt = arg .UpdatedAt
@@ -1540,7 +1557,7 @@ func (q *fakeQuerier) UpdateWorkspaceAgentConnectionByID(_ context.Context, arg
15401557 defer q .mutex .Unlock ()
15411558
15421559 for index , agent := range q .provisionerJobAgents {
1543- if agent .ID . String () != arg .ID . String () {
1560+ if agent .ID != arg .ID {
15441561 continue
15451562 }
15461563 agent .FirstConnectedAt = arg .FirstConnectedAt
@@ -1557,7 +1574,7 @@ func (q *fakeQuerier) UpdateProvisionerJobByID(_ context.Context, arg database.U
15571574 defer q .mutex .Unlock ()
15581575
15591576 for index , job := range q .provisionerJobs {
1560- if arg .ID . String () != job .ID . String () {
1577+ if arg .ID != job .ID {
15611578 continue
15621579 }
15631580 job .UpdatedAt = arg .UpdatedAt
@@ -1572,7 +1589,7 @@ func (q *fakeQuerier) UpdateProvisionerJobWithCancelByID(_ context.Context, arg
15721589 defer q .mutex .Unlock ()
15731590
15741591 for index , job := range q .provisionerJobs {
1575- if arg .ID . String () != job .ID . String () {
1592+ if arg .ID != job .ID {
15761593 continue
15771594 }
15781595 job .CanceledAt = arg .CanceledAt
@@ -1587,7 +1604,7 @@ func (q *fakeQuerier) UpdateProvisionerJobWithCompleteByID(_ context.Context, ar
15871604 defer q .mutex .Unlock ()
15881605
15891606 for index , job := range q .provisionerJobs {
1590- if arg .ID . String () != job .ID . String () {
1607+ if arg .ID != job .ID {
15911608 continue
15921609 }
15931610 job .UpdatedAt = arg .UpdatedAt
@@ -1604,7 +1621,7 @@ func (q *fakeQuerier) UpdateWorkspaceAutostart(_ context.Context, arg database.U
16041621 defer q .mutex .Unlock ()
16051622
16061623 for index , workspace := range q .workspaces {
1607- if workspace .ID . String () != arg .ID . String () {
1624+ if workspace .ID != arg .ID {
16081625 continue
16091626 }
16101627 workspace .AutostartSchedule = arg .AutostartSchedule
@@ -1620,7 +1637,7 @@ func (q *fakeQuerier) UpdateWorkspaceAutostop(_ context.Context, arg database.Up
16201637 defer q .mutex .Unlock ()
16211638
16221639 for index , workspace := range q .workspaces {
1623- if workspace .ID . String () != arg .ID . String () {
1640+ if workspace .ID != arg .ID {
16241641 continue
16251642 }
16261643 workspace .AutostopSchedule = arg .AutostopSchedule
@@ -1636,7 +1653,7 @@ func (q *fakeQuerier) UpdateWorkspaceBuildByID(_ context.Context, arg database.U
16361653 defer q .mutex .Unlock ()
16371654
16381655 for index , workspaceBuild := range q .workspaceBuilds {
1639- if workspaceBuild .ID . String () != arg .ID . String () {
1656+ if workspaceBuild .ID != arg .ID {
16401657 continue
16411658 }
16421659 workspaceBuild .UpdatedAt = arg .UpdatedAt
@@ -1653,7 +1670,7 @@ func (q *fakeQuerier) UpdateWorkspaceDeletedByID(_ context.Context, arg database
16531670 defer q .mutex .Unlock ()
16541671
16551672 for index , workspace := range q .workspaces {
1656- if workspace .ID . String () != arg .ID . String () {
1673+ if workspace .ID != arg .ID {
16571674 continue
16581675 }
16591676 workspace .Deleted = arg .Deleted
0 commit comments