@@ -4121,46 +4121,45 @@ func TestDocumentChannelHistoryCompact(t *testing.T) {
41214121 version = rt .UpdateDoc ("doc12" , version , `{"channels": ["a"]}` )
41224122 _ = rt .UpdateDoc ("doc12" , version , `{"channels": ["a", "c"]}` )
41234123 req := CompactDocChannelHistoryRequest {
4124- DocIds : []string {"doc11" , "doc12" },
4125- Seq : 999999 ,
4124+ Seq : 999999 ,
41264125 }
41274126
41284127 bodyBytes , err := base .JSONMarshal (req )
41294128 require .NoError (t , err )
4130- resp := rt .SendAdminRequest ("POST" , "/{{.keyspace}}/_channel_history/_compact " , string (bodyBytes ))
4129+ resp := rt .SendAdminRequest ("POST" , "/{{.keyspace}}/_channel_history/doc11/compact " , string (bodyBytes ))
41314130 RequireStatus (t , resp , http .StatusOK )
41324131
4133- var chanOutput map [string ][]string
4134- err = base .JSONUnmarshal (resp .Body .Bytes (), & chanOutput )
4132+ var chanOutput1 map [string ][]string
4133+ err = base .JSONUnmarshal (resp .Body .Bytes (), & chanOutput1 )
41354134 require .NoError (t , err )
41364135
4137- expectedOutput := map [string ][]string {
4138- "doc11" : []string {"test" },
4139- "doc12" : []string {"b" },
4136+ expectedOutput1 := map [string ][]string {
4137+ "compacted_channels" : []string {"test" },
41404138 }
41414139
4142- assert .Equal (t , expectedOutput , chanOutput )
4143- })
4140+ assert .Equal (t , expectedOutput1 , chanOutput1 )
41444141
4145- t .Run ("empty doc_ids returns 400" , func (t * testing.T ) {
4146- req := CompactDocChannelHistoryRequest {
4147- DocIds : []string {},
4148- Seq : 1 ,
4149- }
4150- bodyBytes , err := base .JSONMarshal (req )
4142+ resp2 := rt .SendAdminRequest ("POST" , "/{{.keyspace}}/_channel_history/doc12/compact" , string (bodyBytes ))
4143+ RequireStatus (t , resp2 , http .StatusOK )
4144+
4145+ var chanOutput2 map [string ][]string
4146+ err = base .JSONUnmarshal (resp2 .Body .Bytes (), & chanOutput2 )
41514147 require .NoError (t , err )
4152- resp := rt .SendAdminRequest ("POST" , "/{{.keyspace}}/_channel_history/_compact" , string (bodyBytes ))
4153- RequireStatus (t , resp , http .StatusBadRequest )
4148+
4149+ expectedOutput2 := map [string ][]string {
4150+ "compacted_channels" : []string {"b" },
4151+ }
4152+
4153+ assert .Equal (t , expectedOutput2 , chanOutput2 )
41544154 })
41554155
41564156 t .Run ("seq zero returns 400" , func (t * testing.T ) {
41574157 req := CompactDocChannelHistoryRequest {
4158- DocIds : []string {"doc1" },
4159- Seq : 0 ,
4158+ Seq : 0 ,
41604159 }
41614160 bodyBytes , err := base .JSONMarshal (req )
41624161 require .NoError (t , err )
4163- resp := rt .SendAdminRequest ("POST" , "/{{.keyspace}}/_channel_history/_compact " , string (bodyBytes ))
4162+ resp := rt .SendAdminRequest ("POST" , "/{{.keyspace}}/_channel_history/doc1/compact " , string (bodyBytes ))
41644163 RequireStatus (t , resp , http .StatusBadRequest )
41654164 })
41664165}
@@ -4271,7 +4270,6 @@ func TestGetDocChannelHistory(t *testing.T) {
42714270 version := rt .PutDoc ("doc1" , `{"channels": ["chan1"]}` )
42724271
42734272 version = rt .UpdateDoc ("doc1" , version , `{"channels": []}` )
4274- chanRevocationSeq1 := rt .GetDocumentSequence ("doc1" )
42754273
42764274 version = rt .UpdateDoc ("doc1" , version , `{"channels": ["chan1","chan2"]}` )
42774275
@@ -4280,25 +4278,25 @@ func TestGetDocChannelHistory(t *testing.T) {
42804278
42814279 rt .UpdateDoc ("doc1" , version , `{"channels": ["chan3","chan2"]}` )
42824280
4283- expectedChanHistory := map [string ][] uint64 {
4284- "chan1" : { chanRevocationSeq2 , chanRevocationSeq1 } ,
4285- "chan2" : { chanRevocationSeq2 } ,
4281+ expectedChanHistory := map [string ]uint64 {
4282+ "chan1" : chanRevocationSeq2 ,
4283+ "chan2" : chanRevocationSeq2 ,
42864284 }
42874285
42884286 chanHistory , err := collection .GetDocChannelHistory (ctx , "doc1" )
42894287 require .NoError (t , err )
42904288 require .Len (t , chanHistory , len (expectedChanHistory ))
4291- for chanName , expectedSeqs := range expectedChanHistory {
4292- assert .ElementsMatch (t , expectedSeqs , chanHistory [chanName ])
4289+ for chanName , expectedSeq := range expectedChanHistory {
4290+ assert .Equal (t , expectedSeq , chanHistory [chanName ])
42934291 }
42944292
42954293 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc1" , "" )
42964294 RequireStatus (t , resp , http .StatusOK )
4297- var apiResult map [string ][] uint64
4295+ var apiResult map [string ]uint64
42984296 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
42994297 require .Len (t , apiResult , len (expectedChanHistory ))
4300- for chanName , expectedSeqs := range expectedChanHistory {
4301- assert .ElementsMatch (t , expectedSeqs , apiResult [chanName ])
4298+ for chanName , expectedSeq := range expectedChanHistory {
4299+ assert .Equal (t , expectedSeq , apiResult [chanName ])
43024300 }
43034301 })
43044302
@@ -4329,15 +4327,15 @@ func TestGetDocChannelHistory(t *testing.T) {
43294327 version := rt .PutDoc ("doc3" , `{"channels": ["chan1"]}` )
43304328 rt .UpdateDoc ("doc3" , version , `{"channels": []}` )
43314329 revocationSeq := rt .GetDocumentSequence ("doc3" )
4332- expected := map [string ][] uint64 {"chan1" : { revocationSeq } }
4330+ expected := map [string ]uint64 {"chan1" : revocationSeq }
43334331
43344332 chanHistory , err := collection .GetDocChannelHistory (ctx , "doc3" )
43354333 require .NoError (t , err )
43364334 assert .Equal (t , expected , chanHistory )
43374335
43384336 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc3" , "" )
43394337 RequireStatus (t , resp , http .StatusOK )
4340- var apiResult map [string ][] uint64
4338+ var apiResult map [string ]uint64
43414339 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
43424340 assert .Equal (t , expected , apiResult )
43434341 })
@@ -4346,10 +4344,10 @@ func TestGetDocChannelHistory(t *testing.T) {
43464344 version := rt .PutDoc ("doc4" , `{"channels": ["chan1", "chan2", "chan3"]}` )
43474345 rt .UpdateDoc ("doc4" , version , `{"channels": []}` )
43484346 revocationSeq := rt .GetDocumentSequence ("doc4" )
4349- expected := map [string ][] uint64 {
4350- "chan1" : { revocationSeq } ,
4351- "chan2" : { revocationSeq } ,
4352- "chan3" : { revocationSeq } ,
4347+ expected := map [string ]uint64 {
4348+ "chan1" : revocationSeq ,
4349+ "chan2" : revocationSeq ,
4350+ "chan3" : revocationSeq ,
43534351 }
43544352
43554353 chanHistory , err := collection .GetDocChannelHistory (ctx , "doc4" )
@@ -4358,7 +4356,7 @@ func TestGetDocChannelHistory(t *testing.T) {
43584356
43594357 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc4" , "" )
43604358 RequireStatus (t , resp , http .StatusOK )
4361- var apiResult map [string ][] uint64
4359+ var apiResult map [string ]uint64
43624360 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
43634361 assert .Equal (t , expected , apiResult )
43644362 })
@@ -4378,7 +4376,7 @@ func TestGetDocChannelHistory(t *testing.T) {
43784376
43794377 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc5" , "" )
43804378 RequireStatus (t , resp , http .StatusOK )
4381- var apiResult map [string ][] uint64
4379+ var apiResult map [string ]uint64
43824380 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
43834381 assert .NotEmpty (t , apiResult ["chan1" ])
43844382 })
@@ -4388,7 +4386,7 @@ func TestGetDocChannelHistory(t *testing.T) {
43884386 version := rt .PutDoc ("doc6" , `{"channels": ["chan1", "chan2"]}` )
43894387 rt .UpdateDoc ("doc6" , version , `{"channels": ["chan2"]}` )
43904388 revocationSeq := rt .GetDocumentSequence ("doc6" )
4391- expected := map [string ][] uint64 {"chan1" : { revocationSeq } }
4389+ expected := map [string ]uint64 {"chan1" : revocationSeq }
43924390
43934391 chanHistory , err := collection .GetDocChannelHistory (ctx , "doc6" )
43944392 require .NoError (t , err )
@@ -4397,7 +4395,7 @@ func TestGetDocChannelHistory(t *testing.T) {
43974395
43984396 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc6" , "" )
43994397 RequireStatus (t , resp , http .StatusOK )
4400- var apiResult map [string ][] uint64
4398+ var apiResult map [string ]uint64
44014399 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
44024400 assert .Equal (t , expected , apiResult )
44034401 })
@@ -4409,15 +4407,15 @@ func TestGetDocChannelHistory(t *testing.T) {
44094407
44104408 // Re-add chan1 — it should still appear in history from the earlier revocation
44114409 rt .UpdateDoc ("doc8" , version , `{"channels": ["chan1"]}` )
4412- expected := map [string ][] uint64 {"chan1" : { revocationSeq } }
4410+ expected := map [string ]uint64 {"chan1" : revocationSeq }
44134411
44144412 chanHistory , err := collection .GetDocChannelHistory (ctx , "doc8" )
44154413 require .NoError (t , err )
44164414 assert .Equal (t , expected , chanHistory )
44174415
44184416 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc8" , "" )
44194417 RequireStatus (t , resp , http .StatusOK )
4420- var apiResult map [string ][] uint64
4418+ var apiResult map [string ]uint64
44214419 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
44224420 assert .Equal (t , expected , apiResult )
44234421 })
0 commit comments