MongoFixtures library for Dart

Build Status

A library for inserting your test fixtures into the MongoDb using mongo_dart.

Usage

A simple usage example:

import 'package:mongo_fixtures/mongo_fixtures.dart' as fixtures;

List<fixtures.Entity> fixturesProvider(fixtures.Loader loader) {
    return [

        new fixtures.Collection('some_collection')
            ..insert(map: {
                'field_one': 'value1',
                'field_two': 'value2',
                'field_three': loader.document('document').field('another_field_one'),
            }),

        new fixtures.Collection('some_another_collection')
            ..insert(map: {
                'another_field_one': 'value3',
                'another_field_two': 'value4',
            })
            ..insert(label: 'document', map: {
                'another_field_one': 'value3',
                'another_field_two': 'value4',
            })

    ];
}

main() {

    group('test group', () {

        setUp(() {
            return new fixtures.Loader('mongodb://127.0.0.1/db_for_test')
                .cleanAllAndInsert(fixturesProvider);
        });

        ...

    });
}

Features and bugs

Please file feature requests and bugs at the issue tracker.

Libraries

mongo_fixtures