mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-23 22:26:27 +01:00
Some checks failed
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,free-days-interop,dependency-freshness) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / free-days-interop (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
release-apk / release (APK) (push) Has been cancelled
Todo: fe70b845
40 lines
1.4 KiB
Dart
40 lines
1.4 KiB
Dart
import 'package:crdt_sync/crdt_sync.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:http/testing.dart';
|
|
import 'package:wake_alarm_sync/services/firebase_backend.dart';
|
|
import 'package:wake_alarm_sync/services/sync_emulator.dart';
|
|
|
|
/// A [RemoteStore] that is only ever compared by identity.
|
|
class _Github extends Fake implements RemoteStore {}
|
|
|
|
void main() {
|
|
test(
|
|
'a build without the define syncs to prod, never the emulator',
|
|
() async {
|
|
expect(kSyncEmulatorUrl, isEmpty);
|
|
expect(syncEmulatorOn, isFalse);
|
|
expect(kProject.databaseUrl, contains('kuhy-syncs'));
|
|
final github = _Github();
|
|
// No Firebase session in tests: prod's rollback path, GitHub alone.
|
|
expect(await syncBackend(github), same(github));
|
|
},
|
|
);
|
|
|
|
test('the emulator client signs as owner against the given origin', () async {
|
|
final seen = <Uri>[];
|
|
final client = emulatorClient(
|
|
url: 'http://10.0.2.2:9000',
|
|
httpClient: MockClient((request) async {
|
|
seen.add(request.url);
|
|
return http.Response('null', 200);
|
|
}),
|
|
);
|
|
await client.listDirectory('wake-alarm-sync/devices-e2e');
|
|
expect(seen.single.origin, 'http://10.0.2.2:9000');
|
|
expect(seen.single.queryParameters['auth'], 'owner');
|
|
expect(await EmulatorTokenProvider().hasSession(), isTrue);
|
|
expect(emulatorAccount.email, 'emulator');
|
|
});
|
|
}
|