fix(config): 指定 API_BASE_URL 时跳过地址探测
This commit is contained in:
1 parent
2c5ff3579c
commit
9ebb54ecfd
2 files changed
+61
No files matched your search
@@ -66,6 +66,59 @@ void main() {
|
||||
expect(AppConfig.devHostBaseUrl, 'http://192.168.31.187:8081');
|
||||
});
|
||||
|
||||
test('should_skip_probe_when_compiled_override_is_set', () async {
|
||||
const compiled = 'http://compiled.test:8081';
|
||||
var probeCalls = 0;
|
||||
|
||||
await AppConfig.probeAndApplyBaseUrl(
|
||||
compiledOverride: compiled,
|
||||
probe: (_) async {
|
||||
probeCalls++;
|
||||
return true;
|
||||
},
|
||||
);
|
||||
|
||||
expect(probeCalls, 0);
|
||||
expect(AppConfig.apiBaseUrl, compiled);
|
||||
});
|
||||
|
||||
test('should_keep_runtime_endpoint_when_compiled_override_is_set', () async {
|
||||
const runtime = 'http://runtime.test:8081';
|
||||
const compiled = 'http://compiled.test:8081';
|
||||
var probeCalls = 0;
|
||||
AppConfig.applyRuntimeBaseUrl(runtime);
|
||||
|
||||
await AppConfig.probeAndApplyBaseUrl(
|
||||
compiledOverride: compiled,
|
||||
probe: (_) async {
|
||||
probeCalls++;
|
||||
return true;
|
||||
},
|
||||
);
|
||||
|
||||
expect(probeCalls, 0);
|
||||
expect(AppConfig.apiBaseUrl, runtime);
|
||||
});
|
||||
|
||||
test('should_keep_probing_when_compiled_override_is_empty', () async {
|
||||
final attempts = <String>[];
|
||||
|
||||
await AppConfig.probeAndApplyBaseUrl(
|
||||
compiledOverride: '',
|
||||
probe: (baseUrl) async {
|
||||
attempts.add(baseUrl);
|
||||
return baseUrl == AppConfig.publicBaseUrl;
|
||||
},
|
||||
);
|
||||
|
||||
expect(attempts, [
|
||||
AppConfig.lanBaseUrl,
|
||||
AppConfig.devHostBaseUrl,
|
||||
AppConfig.publicBaseUrl,
|
||||
]);
|
||||
expect(AppConfig.apiBaseUrl, AppConfig.publicBaseUrl);
|
||||
});
|
||||
|
||||
test(
|
||||
'should_probe_all_candidates_in_parallel_before_applying_priority',
|
||||
() async {
|
||||
|
||||
Reference in new issue
Block a user