LCOV - code coverage report
Current view: top level - src - testainers_mongodb.dart (source / functions) Coverage Total Hit
Test: testainers Lines: 100.0 % 11 11
Test Date: 2026-05-24 17:06:20 Functions: - 0 0

            Line data    Source code
       1              : import 'package:testainers/src/testainers_base.dart';
       2              : import 'package:testainers/src/testainers_utils.dart';
       3              : 
       4              : class TestainersMongodb extends Testainers {
       5              :   final String? _username;
       6              :   final String? _password;
       7              :   int? _port;
       8              : 
       9            1 :   TestainersMongodb({
      10              :     String? username,
      11              :     String? password,
      12              :     int? port,
      13              :     super.config,
      14              :     super.name,
      15              :     super.image = 'mongo',
      16              :     super.tag = '7.0',
      17              :     super.ports = const <int, int>{},
      18              :     super.env = const <String, String>{},
      19              :     super.detached = true,
      20              :     super.remove = true,
      21              :     super.links,
      22              :     super.networks,
      23              :     super.healthCmd = 'echo \'db.runCommand("ping").ok\' | '
      24              :         'mongosh localhost:27017/test --quiet',
      25              :     super.healthInterval = 5,
      26              :     super.healthRetries = 2,
      27              :     super.healthTimeout = 3,
      28              :     super.healthStartPeriod = 1,
      29              :     super.noHealthcheck,
      30              :     super.stopTime,
      31              :   })  : _username = username,
      32              :         _password = password,
      33              :         _port = port;
      34              : 
      35            4 :   String get username => _username ?? config.defaultUsername;
      36              : 
      37            4 :   String get password => _password ?? config.defaultPassword;
      38              : 
      39            2 :   int get port => _port ?? -1;
      40              : 
      41            1 :   @override
      42              :   Future<Map<int, int>> portsFilter(Map<int, int> ports) async {
      43            2 :     _port ??= await TestainersUtils.generatePort();
      44            3 :     return <int, int>{...ports, _port!: 27017};
      45              :   }
      46              : 
      47            1 :   @override
      48              :   Future<Map<String, String>> envFilter(Map<String, String> env) async =>
      49            1 :       <String, String>{
      50              :         ...env,
      51            2 :         'MONGO_INITDB_ROOT_USERNAME': username,
      52            2 :         'MONGO_INITDB_ROOT_PASSWORD': password,
      53              :       };
      54              : }
        

Generated by: LCOV version 2.0-1