@@ -4052,6 +4052,15 @@ func TestDocumentChannelHistoryCompact(t *testing.T) {
40524052 // Compacting nonexistent doc should return not found error
40534053 _ , err := collection .CompactDocChannelHistory (ctx , "nonexistent" , 1 )
40544054 assert .Error (t , err )
4055+
4056+ req := CompactDocChannelHistoryRequest {
4057+ Seq : 999999 ,
4058+ }
4059+
4060+ bodyBytes , err := base .JSONMarshal (req )
4061+ require .NoError (t , err )
4062+ resp := rt .SendAdminRequest ("POST" , "/{{.keyspace}}/_channel_history/nonexistent/compact" , string (bodyBytes ))
4063+ RequireStatus (t , resp , http .StatusNotFound )
40554064 })
40564065
40574066 t .Run ("multiple channels with mixed history" , func (t * testing.T ) {
@@ -4282,6 +4291,7 @@ func TestGetDocChannelHistory(t *testing.T) {
42824291 version := rt .PutDoc ("doc1" , `{"channels": ["chan1"]}` )
42834292
42844293 version = rt .UpdateDoc ("doc1" , version , `{"channels": []}` )
4294+ chanRevocationSeq1 := rt .GetDocumentSequence ("doc1" )
42854295
42864296 version = rt .UpdateDoc ("doc1" , version , `{"channels": ["chan1","chan2"]}` )
42874297
@@ -4290,21 +4300,21 @@ func TestGetDocChannelHistory(t *testing.T) {
42904300
42914301 rt .UpdateDoc ("doc1" , version , `{"channels": ["chan3","chan2"]}` )
42924302
4293- expectedChanHistory := map [string ]uint64 {
4294- "chan1" : chanRevocationSeq2 ,
4295- "chan2" : chanRevocationSeq2 ,
4303+ expectedChanHistory := map [string ][] uint64 {
4304+ "chan1" : { chanRevocationSeq2 , chanRevocationSeq1 } ,
4305+ "chan2" : { chanRevocationSeq2 } ,
42964306 }
42974307
42984308 chanHistory , err := collection .GetDocChannelHistory (ctx , "doc1" )
42994309 require .NoError (t , err )
43004310 require .Len (t , chanHistory , len (expectedChanHistory ))
43014311 for chanName , expectedSeq := range expectedChanHistory {
4302- assert .Equal (t , expectedSeq , chanHistory [chanName ])
4312+ assert .ElementsMatch (t , expectedSeq , chanHistory [chanName ])
43034313 }
43044314
43054315 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc1" , "" )
43064316 RequireStatus (t , resp , http .StatusOK )
4307- var apiResult map [string ]uint64
4317+ var apiResult map [string ][] uint64
43084318 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
43094319 require .Len (t , apiResult , len (expectedChanHistory ))
43104320 for chanName , expectedSeq := range expectedChanHistory {
@@ -4339,15 +4349,15 @@ func TestGetDocChannelHistory(t *testing.T) {
43394349 version := rt .PutDoc ("doc3" , `{"channels": ["chan1"]}` )
43404350 rt .UpdateDoc ("doc3" , version , `{"channels": []}` )
43414351 revocationSeq := rt .GetDocumentSequence ("doc3" )
4342- expected := map [string ]uint64 {"chan1" : revocationSeq }
4352+ expected := map [string ][] uint64 {"chan1" : { revocationSeq } }
43434353
43444354 chanHistory , err := collection .GetDocChannelHistory (ctx , "doc3" )
43454355 require .NoError (t , err )
43464356 assert .Equal (t , expected , chanHistory )
43474357
43484358 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc3" , "" )
43494359 RequireStatus (t , resp , http .StatusOK )
4350- var apiResult map [string ]uint64
4360+ var apiResult map [string ][] uint64
43514361 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
43524362 assert .Equal (t , expected , apiResult )
43534363 })
@@ -4356,10 +4366,10 @@ func TestGetDocChannelHistory(t *testing.T) {
43564366 version := rt .PutDoc ("doc4" , `{"channels": ["chan1", "chan2", "chan3"]}` )
43574367 rt .UpdateDoc ("doc4" , version , `{"channels": []}` )
43584368 revocationSeq := rt .GetDocumentSequence ("doc4" )
4359- expected := map [string ]uint64 {
4360- "chan1" : revocationSeq ,
4361- "chan2" : revocationSeq ,
4362- "chan3" : revocationSeq ,
4369+ expected := map [string ][] uint64 {
4370+ "chan1" : { revocationSeq } ,
4371+ "chan2" : { revocationSeq } ,
4372+ "chan3" : { revocationSeq } ,
43634373 }
43644374
43654375 chanHistory , err := collection .GetDocChannelHistory (ctx , "doc4" )
@@ -4368,7 +4378,7 @@ func TestGetDocChannelHistory(t *testing.T) {
43684378
43694379 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc4" , "" )
43704380 RequireStatus (t , resp , http .StatusOK )
4371- var apiResult map [string ]uint64
4381+ var apiResult map [string ][] uint64
43724382 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
43734383 assert .Equal (t , expected , apiResult )
43744384 })
@@ -4388,7 +4398,7 @@ func TestGetDocChannelHistory(t *testing.T) {
43884398
43894399 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc5" , "" )
43904400 RequireStatus (t , resp , http .StatusOK )
4391- var apiResult map [string ]uint64
4401+ var apiResult map [string ][] uint64
43924402 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
43934403 assert .NotEmpty (t , apiResult ["chan1" ])
43944404 })
@@ -4398,7 +4408,7 @@ func TestGetDocChannelHistory(t *testing.T) {
43984408 version := rt .PutDoc ("doc6" , `{"channels": ["chan1", "chan2"]}` )
43994409 rt .UpdateDoc ("doc6" , version , `{"channels": ["chan2"]}` )
44004410 revocationSeq := rt .GetDocumentSequence ("doc6" )
4401- expected := map [string ]uint64 {"chan1" : revocationSeq }
4411+ expected := map [string ][] uint64 {"chan1" : { revocationSeq } }
44024412
44034413 chanHistory , err := collection .GetDocChannelHistory (ctx , "doc6" )
44044414 require .NoError (t , err )
@@ -4407,7 +4417,7 @@ func TestGetDocChannelHistory(t *testing.T) {
44074417
44084418 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc6" , "" )
44094419 RequireStatus (t , resp , http .StatusOK )
4410- var apiResult map [string ]uint64
4420+ var apiResult map [string ][] uint64
44114421 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
44124422 assert .Equal (t , expected , apiResult )
44134423 })
@@ -4419,15 +4429,15 @@ func TestGetDocChannelHistory(t *testing.T) {
44194429
44204430 // Re-add chan1 — it should still appear in history from the earlier revocation
44214431 rt .UpdateDoc ("doc8" , version , `{"channels": ["chan1"]}` )
4422- expected := map [string ]uint64 {"chan1" : revocationSeq }
4432+ expected := map [string ][] uint64 {"chan1" : { revocationSeq } }
44234433
44244434 chanHistory , err := collection .GetDocChannelHistory (ctx , "doc8" )
44254435 require .NoError (t , err )
44264436 assert .Equal (t , expected , chanHistory )
44274437
44284438 resp := rt .SendAdminRequest ("GET" , "/{{.keyspace}}/_channel_history/doc8" , "" )
44294439 RequireStatus (t , resp , http .StatusOK )
4430- var apiResult map [string ]uint64
4440+ var apiResult map [string ][] uint64
44314441 require .NoError (t , json .Unmarshal (resp .BodyBytes (), & apiResult ))
44324442 assert .Equal (t , expected , apiResult )
44334443 })
0 commit comments