2017-07-07 68 views
0

当渡槽实施的OAuth我错误地没有按照测试驱动开发思想,我现在为它付出...丢失配置文件测试 - 渡槽

当我运行我的测试中,我得到的错误:

"No configuration file found. See README.md." 

这是从initializeApplication方法在我AppSink类抛出。 据我了解,测试利用config.src.yaml文件,所以我有相应的配置我的测试工具:

application = new Application<OdexSink>(); 
application.configuration.port = 0; 
application.configuration.configurationFilePath = "config.src.yaml"; 

因为我是能够运行测试我实现了AuthServer等之前,我怀疑它发生在一路上。

我的测试设置如下:

var app = new Application<OdexSink>(); 
TestClient client; 

setUp(() async { 
    await app.start(runOnMainIsolate: true); 
    client = new TestClient(app); 

    var ctx = ManagedContext.defaultContext; 
    var builder = new SchemaBuilder.toSchema(ctx.persistentStore, new Schema.fromDataModel(ctx.dataModel), isTemporary: true); 

    for (var cmd in builder.commands) { 
    await ctx.persistentStore.execute(cmd); 
    } 
}); 

而且我的测试工具start()方法是:

Future start() async { 
    RequestController.letUncaughtExceptionsEscape = true; 
    application = new Application<OdexSink>(); 
    application.configuration.port = 0; 
    application.configuration.configurationFilePath = "config.src.yaml"; 

    await application.start(runOnMainIsolate: true); 

    await createDatabaseSchema(ManagedContext.defaultContext, sink.logger); 
    await addClientRecord(); 
    await addClientRecord(clientID: DefaultClientID, clientSecret: DefaultClientSecret); 

    client = new TestClient(application) 
    ..clientID = DefaultClientID 
    ..clientSecret = DefaultClientSecret; 
} 

我config.src.yaml文件退出,并包含DB信息。

回答

1

啊,只是一件小事 - 在您的setUp方法中,您正在创建并启动Application而不是TestApplication线束。它应该是这样的

var app = new TestApplication(); 

setUp(() async { 
    await app.start(); 
}); 

所有在系统中的其它东西已经在您的测试工具完成,你可以使用TestClient的为app.client

expect(await app.client.request("/endpoint"), hasStatus(200));