@@ -28,6 +28,8 @@ func TestHttpAssertInsert(t *testing.T) {
2828 HttpAssertId : assertID .Bytes (),
2929 HttpId : httpID .Bytes (),
3030 Value : expression ,
31+ Enabled : true ,
32+ Order : 1.5 ,
3133 },
3234 },
3335 })
@@ -49,6 +51,50 @@ func TestHttpAssertInsert(t *testing.T) {
4951 }
5052 require .NotNil (t , found , "assert not found in collection" )
5153 require .Equal (t , expression , found .Value )
54+ require .True (t , found .Enabled )
55+ require .Equal (t , float32 (1.5 ), found .Order )
56+ }
57+
58+ func TestHttpAssertInsert_EnabledFalse (t * testing.T ) {
59+ t .Parallel ()
60+ f := newHttpFixture (t )
61+ wsID := f .createWorkspace (t , "test-workspace" )
62+ httpID := f .createHttp (t , wsID , "test-http" )
63+
64+ assertID := idwrap .NewNow ()
65+ expression := "response.status == 200"
66+
67+ req := connect .NewRequest (& httpv1.HttpAssertInsertRequest {
68+ Items : []* httpv1.HttpAssertInsert {
69+ {
70+ HttpAssertId : assertID .Bytes (),
71+ HttpId : httpID .Bytes (),
72+ Value : expression ,
73+ Enabled : false ,
74+ Order : 2.0 ,
75+ },
76+ },
77+ })
78+
79+ _ , err := f .handler .HttpAssertInsert (f .ctx , req )
80+ require .NoError (t , err )
81+
82+ // Verify insertion via Collection
83+ colReq := connect .NewRequest (& emptypb.Empty {})
84+ resp , err := f .handler .HttpAssertCollection (f .ctx , colReq )
85+ require .NoError (t , err )
86+
87+ var found * httpv1.HttpAssert
88+ for _ , item := range resp .Msg .Items {
89+ if string (item .HttpAssertId ) == string (assertID .Bytes ()) {
90+ found = item
91+ break
92+ }
93+ }
94+ require .NotNil (t , found , "assert not found in collection" )
95+ require .Equal (t , expression , found .Value )
96+ require .False (t , found .Enabled , "enabled should be false" )
97+ require .Equal (t , float32 (2.0 ), found .Order )
5298}
5399
54100func TestHttpAssertInsert_Errors (t * testing.T ) {
@@ -91,14 +137,15 @@ func TestHttpAssertUpdate(t *testing.T) {
91137 assertID := idwrap .NewNow ()
92138 // Manually create assertion to control ID
93139 assertion := & mhttp.HTTPAssert {
94- ID : assertID ,
95- HttpID : httpID ,
96- Value : "response.status == 200" ,
97- Description : "desc" ,
98- Enabled : true ,
99- IsDelta : false ,
100- CreatedAt : time .Now ().Unix (),
101- UpdatedAt : time .Now ().Unix (),
140+ ID : assertID ,
141+ HttpID : httpID ,
142+ Value : "response.status == 200" ,
143+ Description : "desc" ,
144+ Enabled : true ,
145+ DisplayOrder : 1.0 ,
146+ IsDelta : false ,
147+ CreatedAt : time .Now ().Unix (),
148+ UpdatedAt : time .Now ().Unix (),
102149 }
103150 err := f .handler .httpAssertService .Create (f .ctx , assertion )
104151 require .NoError (t , err )
@@ -130,6 +177,63 @@ func TestHttpAssertUpdate(t *testing.T) {
130177 }
131178 require .NotNil (t , found )
132179 require .Equal (t , newValue , found .Value )
180+ require .True (t , found .Enabled , "enabled should remain true" )
181+ require .Equal (t , float32 (1.0 ), found .Order , "order should remain unchanged" )
182+ }
183+
184+ func TestHttpAssertUpdate_EnabledAndOrder (t * testing.T ) {
185+ t .Parallel ()
186+ f := newHttpFixture (t )
187+ wsID := f .createWorkspace (t , "test-workspace" )
188+ httpID := f .createHttp (t , wsID , "test-http" )
189+
190+ assertID := idwrap .NewNow ()
191+ assertion := & mhttp.HTTPAssert {
192+ ID : assertID ,
193+ HttpID : httpID ,
194+ Value : "response.status == 200" ,
195+ Description : "desc" ,
196+ Enabled : true ,
197+ DisplayOrder : 1.0 ,
198+ IsDelta : false ,
199+ CreatedAt : time .Now ().Unix (),
200+ UpdatedAt : time .Now ().Unix (),
201+ }
202+ err := f .handler .httpAssertService .Create (f .ctx , assertion )
203+ require .NoError (t , err )
204+
205+ // Update enabled to false and order to 5.5
206+ newEnabled := false
207+ newOrder := float32 (5.5 )
208+ req := connect .NewRequest (& httpv1.HttpAssertUpdateRequest {
209+ Items : []* httpv1.HttpAssertUpdate {
210+ {
211+ HttpAssertId : assertID .Bytes (),
212+ Enabled : & newEnabled ,
213+ Order : & newOrder ,
214+ },
215+ },
216+ })
217+
218+ _ , err = f .handler .HttpAssertUpdate (f .ctx , req )
219+ require .NoError (t , err )
220+
221+ // Verify update
222+ colReq := connect .NewRequest (& emptypb.Empty {})
223+ resp , err := f .handler .HttpAssertCollection (f .ctx , colReq )
224+ require .NoError (t , err )
225+
226+ var found * httpv1.HttpAssert
227+ for _ , item := range resp .Msg .Items {
228+ if string (item .HttpAssertId ) == string (assertID .Bytes ()) {
229+ found = item
230+ break
231+ }
232+ }
233+ require .NotNil (t , found )
234+ require .Equal (t , "response.status == 200" , found .Value , "value should remain unchanged" )
235+ require .False (t , found .Enabled , "enabled should be updated to false" )
236+ require .Equal (t , float32 (5.5 ), found .Order , "order should be updated to 5.5" )
133237}
134238
135239func TestHttpAssertUpdate_Errors (t * testing.T ) {
@@ -254,3 +358,66 @@ func TestHttpAssertCollection(t *testing.T) {
254358 require .NoError (t , err )
255359 require .Len (t , resp .Msg .Items , 3 )
256360}
361+
362+ func TestHttpAssertCollection_VerifyEnabledAndOrder (t * testing.T ) {
363+ t .Parallel ()
364+ f := newHttpFixture (t )
365+ wsID := f .createWorkspace (t , "test-workspace" )
366+ httpID := f .createHttp (t , wsID , "test-http" )
367+
368+ assertID1 := idwrap .NewNow ()
369+ assertion1 := & mhttp.HTTPAssert {
370+ ID : assertID1 ,
371+ HttpID : httpID ,
372+ Value : "response.status == 200" ,
373+ Description : "enabled assertion" ,
374+ Enabled : true ,
375+ DisplayOrder : 1.5 ,
376+ IsDelta : false ,
377+ CreatedAt : time .Now ().Unix (),
378+ UpdatedAt : time .Now ().Unix (),
379+ }
380+ err := f .handler .httpAssertService .Create (f .ctx , assertion1 )
381+ require .NoError (t , err )
382+
383+ assertID2 := idwrap .NewNow ()
384+ assertion2 := & mhttp.HTTPAssert {
385+ ID : assertID2 ,
386+ HttpID : httpID ,
387+ Value : "response.body.length > 0" ,
388+ Description : "disabled assertion" ,
389+ Enabled : false ,
390+ DisplayOrder : 2.5 ,
391+ IsDelta : false ,
392+ CreatedAt : time .Now ().Unix (),
393+ UpdatedAt : time .Now ().Unix (),
394+ }
395+ err = f .handler .httpAssertService .Create (f .ctx , assertion2 )
396+ require .NoError (t , err )
397+
398+ colReq := connect .NewRequest (& emptypb.Empty {})
399+ resp , err := f .handler .HttpAssertCollection (f .ctx , colReq )
400+ require .NoError (t , err )
401+ require .Len (t , resp .Msg .Items , 2 )
402+
403+ // Find and verify first assertion
404+ var found1 , found2 * httpv1.HttpAssert
405+ for _ , item := range resp .Msg .Items {
406+ if string (item .HttpAssertId ) == string (assertID1 .Bytes ()) {
407+ found1 = item
408+ }
409+ if string (item .HttpAssertId ) == string (assertID2 .Bytes ()) {
410+ found2 = item
411+ }
412+ }
413+
414+ require .NotNil (t , found1 , "assertion 1 not found" )
415+ require .Equal (t , "response.status == 200" , found1 .Value )
416+ require .True (t , found1 .Enabled , "assertion 1 should be enabled" )
417+ require .Equal (t , float32 (1.5 ), found1 .Order , "assertion 1 order should be 1.5" )
418+
419+ require .NotNil (t , found2 , "assertion 2 not found" )
420+ require .Equal (t , "response.body.length > 0" , found2 .Value )
421+ require .False (t , found2 .Enabled , "assertion 2 should be disabled" )
422+ require .Equal (t , float32 (2.5 ), found2 .Order , "assertion 2 order should be 2.5" )
423+ }
0 commit comments