From 43a7efa1aa4c446273887e6fa5ebfa1afd1bdb51 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 18 Mar 2025 00:31:39 +0100 Subject: [PATCH] Fix up more test cases --- test/mod_list_test.dart | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/test/mod_list_test.dart b/test/mod_list_test.dart index 7d25d3d..f11c637 100644 --- a/test/mod_list_test.dart +++ b/test/mod_list_test.dart @@ -199,8 +199,10 @@ void main() { list.disableAll(); list.setEnabled('prepatcher', true); final order = list.loadRequired(); + + final expected = ['harmony', 'prepatcher']; expect(order.errors, isEmpty); - expect(order.loadOrder.indexOf('harmony'), isNot(-1)); + expect(order.loadOrder, equals(expected)); }); test('Only required mods should be enabled', () { @@ -217,9 +219,10 @@ void main() { list.disableAll(); list.setEnabled('prepatcher', true); final order = list.loadRequired(); + + final expected = ['harmony', 'prepatcher']; expect(order.errors, isEmpty); - expect(order.loadOrder.indexOf('harmony'), isNot(-1)); - expect(order.loadOrder.indexOf('dummy'), -1); + expect(order.loadOrder, equals(expected)); }); test('Incompatible mods should return errors', () { @@ -241,9 +244,13 @@ void main() { list.setEnabled('incompatible', true); list.setEnabled('prepatcher', true); final result = list.loadRequired(); + + // We say the mods are incompatible but load them anyway, who are we to decide what isn't loaded? + final expected = ['harmony', 'prepatcher', 'incompatible']; expect(result.errors, isNotEmpty); expect(result.errors.any((e) => e.contains('incompatible')), isTrue); expect(result.errors.any((e) => e.contains('harmony')), isTrue); + expect(result.loadOrder, equals(expected)); }); test('Dependencies of dependencies should be loaded', () { final list = ModList(); @@ -263,10 +270,10 @@ void main() { list.disableAll(); list.setEnabled('modA', true); final order = list.loadRequired(); + + final expected = ['modC', 'modB', 'modA']; expect(order.errors, isEmpty); - expect(order.loadOrder.indexOf('modA'), isNot(-1)); - expect(order.loadOrder.indexOf('modB'), isNot(-1)); - expect(order.loadOrder.indexOf('modC'), isNot(-1)); + expect(order.loadOrder, equals(expected)); }); }); @@ -293,10 +300,15 @@ void main() { list.disableAll(); list.setEnabled('modA', true); final result = list.loadRequired(); + + // We try to not disable mods...... But cyclic dependencies are just hell + // Can not handle it + final expected = []; expect(result.errors, isNotEmpty); expect(result.errors.any((e) => e.contains('modA')), isTrue); expect(result.errors.any((e) => e.contains('modB')), isTrue); expect(result.errors.any((e) => e.contains('modC')), isTrue); + expect(result.loadOrder, equals(expected)); }); }); @@ -317,13 +329,9 @@ void main() { list.enableAll(); final order = list.generateLoadOrder(); - final aIndex = order.loadOrder.indexOf('modA'); - final bIndex = order.loadOrder.indexOf('modB'); - final cIndex = order.loadOrder.indexOf('modC'); - + final expected = ['modB', 'modA', 'modC']; expect(order.errors, isEmpty); - expect(aIndex, greaterThan(bIndex)); - expect(aIndex, lessThan(cIndex)); + expect(order.loadOrder, equals(expected)); }); });