@@ -81,6 +81,10 @@ func TestGetWorkspaceBuild(t *testing.T) {
81
81
CreatedAt : time .Now ().Add (time .Hour ),
82
82
}),
83
83
}
84
+ orderBuilds = []database.WorkspaceBuildThin {
85
+ builds [1 ],
86
+ builds [0 ],
87
+ }
84
88
ctx = context .Background ()
85
89
)
86
90
@@ -109,13 +113,13 @@ func TestGetWorkspaceBuild(t *testing.T) {
109
113
110
114
t .Run ("GetWorkspaceBuildsCreatedAfter" , func (t * testing.T ) {
111
115
t .Parallel ()
112
- builds , err := db .GetWorkspaceBuildsCreatedAfter (ctx , jobs [0 ].CreatedAt )
116
+ found , err := db .GetWorkspaceBuildsCreatedAfter (ctx , builds [0 ].CreatedAt . Add ( time . Second ) )
113
117
if err != nil {
114
118
t .Fatal (err )
115
119
}
116
120
expected := builds [1 ]
117
- require .Len (t , builds , 1 , "should only be one build" )
118
- require .Equal (t , expected , builds [0 ], "builds should be equal" )
121
+ require .Len (t , found , 1 , "should only be one build" )
122
+ require .Equal (t , expected , found [0 ]. ToThin () , "builds should be equal" )
119
123
})
120
124
121
125
t .Run ("GetWorkspaceBuildByWorkspaceIDAndBuildNumber" , func (t * testing.T ) {
@@ -142,11 +146,7 @@ func TestGetWorkspaceBuild(t *testing.T) {
142
146
t .Fatal (err )
143
147
}
144
148
require .Len (t , found , 2 , "should be two builds" )
145
- exp := []database.WorkspaceBuildThin {
146
- builds [1 ],
147
- builds [0 ],
148
- }
149
- require .Equal (t , exp , toThins (found ), "builds should be equal" )
149
+ require .Equal (t , orderBuilds , toThins (found ), "builds should be equal" )
150
150
})
151
151
152
152
t .Run ("GetLatestWorkspaceBuildsByWorkspaceIDs" , func (t * testing.T ) {
@@ -155,8 +155,8 @@ func TestGetWorkspaceBuild(t *testing.T) {
155
155
if err != nil {
156
156
t .Fatal (err )
157
157
}
158
- require .Len (t , found , 2 , "should be two builds " )
159
- require .Equal (t , builds , found , "builds should be equal" )
158
+ require .Len (t , found , 1 , "should be only one build " )
159
+ require .Equal (t , builds [ 1 ] , found [ 0 ]. ToThin () , "builds should be equal" )
160
160
})
161
161
162
162
t .Run ("GetLatestWorkspaceBuilds" , func (t * testing.T ) {
@@ -166,7 +166,7 @@ func TestGetWorkspaceBuild(t *testing.T) {
166
166
t .Fatal (err )
167
167
}
168
168
require .Len (t , found , 1 , "should be only 1 build" )
169
- require .Equal (t , builds [1 ], toThins ( found ), "builds should be equal" )
169
+ require .Equal (t , builds [1 ], found [ 0 ]. ToThin ( ), "builds should be equal" )
170
170
})
171
171
172
172
t .Run ("GetLatestWorkspaceBuildByWorkspaceID" , func (t * testing.T ) {
@@ -175,7 +175,7 @@ func TestGetWorkspaceBuild(t *testing.T) {
175
175
if err != nil {
176
176
t .Fatal (err )
177
177
}
178
- require .Equal (t , builds [1 ], found , "builds should be equal" )
178
+ require .Equal (t , builds [1 ], found . ToThin () , "builds should be equal" )
179
179
})
180
180
}
181
181
0 commit comments