Arthur Daniel
Arthur Daniel

Reputation: 341

Missing Configuration File For Tests - Aqueduct

When implementing OAuth with aqueduct I mistakenly didn't follow the test driven development ideology, and I am paying for it now...

When I run my tests, I get the error:

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

Which is thrown from the initializeApplication method in my AppSink class. As I understand it, tests make use of the config.src.yaml file so I have configured my test harness accordingly:

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

Since I was able to run the tests before I implemented the AuthServer etc, I suspect it happened along the way.

My test setUp is as follows:

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);
   }
});

And my Test harness start() method is:

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;
}

My config.src.yaml file exits, and contains DB information.

Upvotes: 0

Views: 72

Answers (1)

Joe Conway
Joe Conway

Reputation: 1586

Ah, just one small thing - in your setUp method, you are creating and starting an Application instead of that TestApplication harness. It should look like this

var app = new TestApplication();

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

All of the other stuff in setUp is already done in your test harness and you can use the TestClient as app.client:

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

Upvotes: 1

Related Questions