@@ -4,12 +4,16 @@ import { LogLevel } from 'noicejs';
4
4
import { Registry } from 'prom-client' ;
5
5
import { spy } from 'sinon' ;
6
6
7
- import { INJECT_METRICS , INJECT_SCHEMA } from '../src/BaseService' ;
7
+ import { INJECT_LOGGER , INJECT_METRICS , INJECT_SCHEMA } from '../src/BaseService' ;
8
8
import { Bot , BotData } from '../src/Bot' ;
9
+ import { Command , CommandVerb } from '../src/entity/Command' ;
9
10
import { BotModule } from '../src/module/BotModule' ;
11
+ import { EntityModule } from '../src/module/EntityModule' ;
12
+ import { MigrationModule } from '../src/module/MigrationModule' ;
10
13
import { ServiceModule } from '../src/module/ServiceModule' ;
11
14
import { Schema } from '../src/schema' ;
12
15
import { ServiceEvent } from '../src/Service' ;
16
+ import { defer } from '../src/utils/Async' ;
13
17
import { describeLeaks , itLeaks } from './helpers/async' ;
14
18
import { createContainer } from './helpers/container' ;
15
19
import { getTestLogger } from './helpers/logger' ;
@@ -36,17 +40,17 @@ const TEST_CONFIG: BotData = {
36
40
parsers : [ ] ,
37
41
process : {
38
42
pid : {
39
- file : '.. /out/isolex .pid' ,
43
+ file : './out/test .pid' ,
40
44
} ,
41
45
} ,
42
46
services : {
43
47
timeout : 1000 ,
44
48
} ,
45
49
storage : {
46
50
data : {
47
- migrate : false ,
51
+ migrate : true ,
48
52
orm : {
49
- database : '' ,
53
+ database : './out/test.db ' ,
50
54
type : 'sqlite' ,
51
55
} ,
52
56
} ,
@@ -97,4 +101,57 @@ describeLeaks('bot service', async () => {
97
101
} ) ;
98
102
expect ( bot . isConnected ) . to . equal ( false ) ;
99
103
} ) ;
104
+
105
+ xit ( 'should execute commands' , async ( ) => {
106
+ const { container } = await createContainer ( new BotModule ( {
107
+ logger : getTestLogger ( ) ,
108
+ } ) , new ServiceModule ( {
109
+ timeout : 1000 ,
110
+ } ) , new EntityModule ( ) , new MigrationModule ( ) ) ;
111
+ const bot = await container . create ( Bot , {
112
+ [ INJECT_LOGGER ] : getTestLogger ( true ) ,
113
+ [ INJECT_SCHEMA ] : new Schema ( ) ,
114
+ data : TEST_CONFIG ,
115
+ metadata : {
116
+ kind : 'bot' ,
117
+ name : 'test-bot' ,
118
+ } ,
119
+ } ) ;
120
+ await bot . start ( ) ;
121
+ const results = await bot . executeCommand ( new Command ( {
122
+ data : { } ,
123
+ labels : { } ,
124
+ noun : 'test' ,
125
+ verb : CommandVerb . Create ,
126
+ } ) ) ;
127
+ await defer ( 50 ) ;
128
+ await bot . stop ( ) ;
129
+ expect ( results . length ) . to . equal ( 0 ) ;
130
+ } ) ;
131
+
132
+ xit ( 'should send messages' , async ( ) => {
133
+ const { container } = await createContainer ( new BotModule ( {
134
+ logger : getTestLogger ( ) ,
135
+ } ) , new ServiceModule ( {
136
+ timeout : 1000 ,
137
+ } ) , new EntityModule ( ) , new MigrationModule ( ) ) ;
138
+ const bot = await container . create ( Bot , {
139
+ [ INJECT_SCHEMA ] : new Schema ( ) ,
140
+ data : TEST_CONFIG ,
141
+ metadata : {
142
+ kind : 'bot' ,
143
+ name : 'test-bot' ,
144
+ } ,
145
+ } ) ;
146
+ await bot . start ( ) ;
147
+ const results = await bot . sendMessage ( /* new Message({
148
+ body: 'test',
149
+ labels: {},
150
+ reactions: [],
151
+ type: TYPE_TEXT,
152
+ }) */ ) ;
153
+ await defer ( 50 ) ;
154
+ await bot . stop ( ) ;
155
+ expect ( results . length ) . to . equal ( 0 ) ;
156
+ } ) ;
100
157
} ) ;
0 commit comments