| 54 | var ErrCantEnqueue = errors.New("cannot push event into the queue") |
| 55 | |
| 56 | func TestQueuePush(t *testing.T) { |
| 57 | var tests = []struct { |
| 58 | name string |
| 59 | e *Event |
| 60 | err error |
| 61 | listeners func() []Listener |
| 62 | enqueueAlways bool |
| 63 | isEnqueued bool |
| 64 | }{ |
| 65 | { |
| 66 | "push event ok", |
| 67 | &Event{ |
| 68 | Type: CreateFile, |
| 69 | Tid: 2484, |
| 70 | PID: 859, |
| 71 | CPU: 1, |
| 72 | Seq: 2, |
| 73 | Name: "CreateFile", |
| 74 | Timestamp: time.Now(), |
| 75 | Category: File, |
| 76 | Params: Params{ |
| 77 | params.FileObject: {Name: params.FileObject, Type: params.Uint64, Value: uint64(12456738026482168384)}, |
| 78 | params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\Windows\\system32\\user32.dll"}, |
| 79 | params.FileType: {Name: params.FileType, Type: params.AnsiString, Value: "file"}, |
| 80 | params.FileOperation: {Name: params.FileOperation, Type: params.Enum, Value: uint32(1), Enum: fs.FileCreateDispositions}, |
| 81 | }, |
| 82 | }, |
| 83 | nil, |
| 84 | func() []Listener { |
| 85 | l := &AddParamListener{} |
| 86 | l.On("ProcessEvent", mock.Anything).Return(true, nil) |
| 87 | return []Listener{l} |
| 88 | }, |
| 89 | true, |
| 90 | true, |
| 91 | }, |
| 92 | { |
| 93 | "push event listener error", |
| 94 | &Event{ |
| 95 | Type: CreateFile, |
| 96 | Tid: 2484, |
| 97 | PID: 859, |
| 98 | CPU: 1, |
| 99 | Seq: 2, |
| 100 | Name: "CreateFile", |
| 101 | Timestamp: time.Now(), |
| 102 | Category: File, |
| 103 | Params: Params{ |
| 104 | params.FileObject: {Name: params.FileObject, Type: params.Uint64, Value: uint64(12456738026482168384)}, |
| 105 | params.FilePath: {Name: params.FilePath, Type: params.UnicodeString, Value: "C:\\Windows\\system32\\user32.dll"}, |
| 106 | params.FileType: {Name: params.FileType, Type: params.AnsiString, Value: "file"}, |
| 107 | params.FileOperation: {Name: params.FileOperation, Type: params.Enum, Value: uint32(1), Enum: fs.FileCreateDispositions}, |
| 108 | }, |
| 109 | }, |
| 110 | ErrCantEnqueue, |
| 111 | func() []Listener { |
| 112 | l := &AddParamListener{} |
| 113 | l.On("ProcessEvent", mock.Anything).Return(true, ErrCantEnqueue) |