@@ -30,7 +30,7 @@ func TestRun_NoYesNoPrompter_Declined(t *testing.T) {
3030 f .Prompter = stubPrompter {ok : false }
3131 opts := & del.Options {
3232 RawMessageRefs : []string {"@a:1" }, Prompter : f .Prompter , IOStreams : ios ,
33- Delete : func (_ context.Context , _ actionmessage.DeleteQuery ) error { return nil },
33+ Delete : func (_ context.Context , _ actionmessage.DeleteQuery ) ( int , error ) { return 0 , nil },
3434 }
3535 err := del .Run (context .Background (), opts )
3636 require .ErrorIs (t , err , command .ErrNotConfirmed )
@@ -42,11 +42,13 @@ func TestRun_YesSkipsPromptCallsDelete(t *testing.T) {
4242 called := false
4343 opts := & del.Options {
4444 RawMessageRefs : []string {"@a:1" , "@a:2" }, Yes : true , Prompter : f .Prompter , IOStreams : ios ,
45- Delete : func (_ context.Context , _ actionmessage.DeleteQuery ) error { called = true ; return nil },
45+ // Two refs requested but Telegram reports only one affected — the
46+ // output must reflect the affected count, not len(refs).
47+ Delete : func (_ context.Context , _ actionmessage.DeleteQuery ) (int , error ) { called = true ; return 1 , nil },
4648 }
4749 require .NoError (t , del .Run (context .Background (), opts ))
4850 require .True (t , called )
49- require .Contains (t , stdout .String (), "deleted" )
51+ require .Contains (t , stdout .String (), "deleted\t 1 " )
5052}
5153
5254func TestRun_PromptAcceptedCallsDelete (t * testing.T ) {
@@ -56,7 +58,7 @@ func TestRun_PromptAcceptedCallsDelete(t *testing.T) {
5658 called := false
5759 opts := & del.Options {
5860 RawMessageRefs : []string {"@a:5" }, Prompter : f .Prompter , IOStreams : ios ,
59- Delete : func (_ context.Context , _ actionmessage.DeleteQuery ) error { called = true ; return nil },
61+ Delete : func (_ context.Context , _ actionmessage.DeleteQuery ) ( int , error ) { called = true ; return 1 , nil },
6062 }
6163 require .NoError (t , del .Run (context .Background (), opts ))
6264 require .True (t , called )
@@ -76,13 +78,21 @@ func TestRun_RevokeOutputsRevoked(t *testing.T) {
7678 f := runtime .NewTestInvocation (t )
7779 opts := & del.Options {
7880 RawMessageRefs : []string {"@a:1" }, Revoke : true , Yes : true , Prompter : f .Prompter , IOStreams : ios ,
79- Delete : func (_ context.Context , _ actionmessage.DeleteQuery ) error { return nil },
81+ Delete : func (_ context.Context , _ actionmessage.DeleteQuery ) ( int , error ) { return 1 , nil },
8082 }
8183 require .NoError (t , del .Run (context .Background (), opts ))
8284 require .Contains (t , stdout .String (), "revoked" )
8385 require .NotContains (t , stdout .String (), "deleted" )
8486}
8587
88+ func TestDecodeDeleteCount (t * testing.T ) {
89+ // Current daemon: integer affected count is used as-is.
90+ require .Equal (t , 3 , del .DecodeDeleteCountForTest ([]byte ("3" ), 5 ))
91+ require .Equal (t , 0 , del .DecodeDeleteCountForTest ([]byte ("0" ), 5 ))
92+ // Older daemon: bare "true" ack doesn't decode -> fall back to requested.
93+ require .Equal (t , 5 , del .DecodeDeleteCountForTest ([]byte ("true" ), 5 ))
94+ }
95+
8696type stubPrompter struct { ok bool }
8797
8898func (s stubPrompter ) Confirm (string , bool ) (bool , error ) { return s .ok , nil }
0 commit comments