mirror of
https://github.com/ultravioletrs/cocos.git
synced 2026-08-07 07:14:50 +00:00
NOISSUE - Enhance event status (#235)
* enhance timeline Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * fix: remove redundant event Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use constant Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * lint Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use typed constant for status Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * refactor status Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * export agent status and state Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * ehance event states Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * fix tests Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * use manager states and status Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * move algo-run to agent package Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * replace literal with constant Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> * replace manager variable with constant Signed-off-by: WashingtonKK <washingtonkigan@gmail.com> --------- Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
This commit is contained in:
committed by
GitHub
parent
355f95771d
commit
c14a6338cc
@@ -16,7 +16,11 @@ var (
|
||||
_ io.Writer = &Stderr{}
|
||||
)
|
||||
|
||||
const bufSize = 1024
|
||||
const (
|
||||
bufSize = 1024
|
||||
algorithmRun = "AlgorithmRun"
|
||||
errorStatus = "Error"
|
||||
)
|
||||
|
||||
type Stdout struct {
|
||||
Logger *slog.Logger
|
||||
@@ -66,7 +70,7 @@ func (s *Stderr) Write(p []byte) (n int, err error) {
|
||||
s.Logger.Error(string(buf[:n]))
|
||||
}
|
||||
|
||||
if err := s.EventSvc.SendEvent("algorithm-run", "error", json.RawMessage{}); err != nil {
|
||||
if err := s.EventSvc.SendEvent(algorithmRun, errorStatus, json.RawMessage{}); err != nil {
|
||||
return len(p), err
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/ultravioletrs/cocos/agent/events/mocks"
|
||||
"github.com/ultravioletrs/cocos/pkg/manager"
|
||||
)
|
||||
|
||||
func TestStdoutWrite(t *testing.T) {
|
||||
@@ -72,7 +73,7 @@ func TestStderrWrite(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mockEventService := mocks.NewService(t)
|
||||
mockEventService.On("SendEvent", "algorithm-run", "error", mock.Anything).Return(nil)
|
||||
mockEventService.On("SendEvent", "AlgorithmRun", manager.Error.String(), mock.Anything).Return(nil)
|
||||
|
||||
stderr := &Stderr{Logger: mglog.NewMock(), EventSvc: mockEventService}
|
||||
n, err := stderr.Write([]byte(tt.input))
|
||||
|
||||
Reference in New Issue
Block a user