@@ -473,3 +473,44 @@ func TestFilePlugin_Process_ConfigApplyRollbackCompleteTopic(t *testing.T) {
473473
474474 assert .Equal (t , expectedResponse .GetInstanceId (), response .GetInstanceId ())
475475}
476+
477+ func TestFilePlugin_Process_ConfigApplyCompleteTopic (t * testing.T ) {
478+ ctx := context .Background ()
479+ instance := protos .GetNginxOssInstance ([]string {})
480+ mockFileManager := & filefakes.FakeFileManagerServiceInterface {}
481+
482+ messagePipe := busfakes .NewFakeMessagePipe ()
483+ agentConfig := types .AgentConfig ()
484+ fakeGrpcConnection := & grpcfakes.FakeGrpcConnectionInterface {}
485+ filePlugin := NewFilePlugin (agentConfig , fakeGrpcConnection )
486+
487+ err := filePlugin .Init (ctx , messagePipe )
488+ require .NoError (t , err )
489+ filePlugin .fileManagerService = mockFileManager
490+ expectedResponse := & mpi.DataPlaneResponse {
491+ MessageMeta : & mpi.MessageMeta {
492+ MessageId : id .GenerateMessageID (),
493+ CorrelationId : "dfsbhj6-bc92-30c1-a9c9-85591422068e" ,
494+ Timestamp : timestamppb .Now (),
495+ },
496+ CommandResponse : & mpi.CommandResponse {
497+ Status : mpi .CommandResponse_COMMAND_STATUS_OK ,
498+ Message : "Config apply successful" ,
499+ Error : "" ,
500+ },
501+ InstanceId : instance .GetInstanceMeta ().GetInstanceId (),
502+ }
503+
504+ filePlugin .Process (ctx , & bus.Message {Topic : bus .ConfigApplyCompleteTopic , Data : expectedResponse })
505+
506+ messages := messagePipe .GetMessages ()
507+ response , ok := messages [0 ].Data .(* mpi.DataPlaneResponse )
508+ assert .True (t , ok )
509+
510+ assert .Equal (t , expectedResponse .GetCommandResponse ().GetStatus (), response .GetCommandResponse ().GetStatus ())
511+ assert .Equal (t , expectedResponse .GetCommandResponse ().GetMessage (), response .GetCommandResponse ().GetMessage ())
512+ assert .Equal (t , expectedResponse .GetCommandResponse ().GetError (), response .GetCommandResponse ().GetError ())
513+ assert .Equal (t , expectedResponse .GetMessageMeta ().GetCorrelationId (), response .GetMessageMeta ().GetCorrelationId ())
514+
515+ assert .Equal (t , expectedResponse .GetInstanceId (), response .GetInstanceId ())
516+ }
0 commit comments