feat(train): the instance names its map source (ADR 0030, D11, D22)

Train's first endpoint of its own, map.source, names the map workouts
are drawn on, for people signed in only, as a provider's key may be in
its style's address: OpenFreeMap's Liberty style where the operator sets
nothing, else MAP_STYLE_URL (HTTPS only) with MAP_SOURCE_NAME,
MAP_ATTRIBUTION and MAP_ABOUT_URL. A model without a table: no
migration. D22 is recorded in ADR 0030.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-28 13:42:28 +01:00
commit dd778cb2cd
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -0,0 +1,36 @@
import 'package:serverpod/serverpod.dart';
import 'package:test/test.dart';
import '../test_tools/serverpod_test_tools.dart';
/// The map the app draws workouts on, as the instance names it (ADR 0030,
/// D11, D22): for the people signed in, as the provider's key may be in it.
void main() {
withServerpod('The map source', (sessionBuilder, endpoints) {
test('names OpenFreeMap to someone signed in, where the operator sets '
'nothing', () async {
final source = await endpoints.map.source(
sessionBuilder.copyWith(
authentication: AuthenticationOverride.authenticationInfo(
const Uuid().v7(),
{},
),
),
);
expect(source.name, 'OpenFreeMap');
expect(source.styleUrl, startsWith('https://tiles.openfreemap.org/'));
});
test('names nothing to nobody signed in', () async {
await expectLater(
endpoints.map.source(
sessionBuilder.copyWith(
authentication: AuthenticationOverride.unauthenticated(),
),
),
throwsA(isA<ServerpodUnauthenticatedException>()),
);
});
});
}