Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

Add helper to convert Observatory URI to WS URI #232

Merged
merged 3 commits into from
Apr 23, 2019

Conversation

DanTup
Copy link
Contributor

@DanTup DanTup commented Apr 23, 2019

This is to make it easier to reuse in devtools+devtools_server (see flutter/devtools#563 (comment)). I don't know if putting it in a utils file is the best place, so let me know if I should move this.

This is to make it easier to reuse in devtools+devtools_server.

See flutter/devtools#563 (comment).
}

test('handles http URIs',
() => check('http://localhost:123/', 'ws://localhost:123/ws'));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this formatting is a bit odd looking. I would suggest using () {
check('http://localhost:123/', 'wss://localhost:123/ws');
}

No need to write this code but if you have a similar situation in the future it might make sense to have a
Map<String, String> of input to expected uris and then have a single test case that
iterates through all key-value pairs in the map expecting that the uris match.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started it that way, but wasn't sure if having only a single test name without descriptions was good. However, it did turn out a mess, so I've changed it to a Map<String, String>. PTAL!

import 'package:test/test.dart';
import 'package:vm_service_lib/utils.dart';

@TestOn('vm')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test should run everywhere, not just on the VM, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I've removed that.

Copy link

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@devoncarew
Copy link
Contributor

@DanTup, let me know if you're not able to merge this PR.

In this PR or a follow-on, we should rev the pubspec and changelog in order to publish this change.

@DanTup
Copy link
Contributor Author

DanTup commented Apr 23, 2019

Pushed changes for the comments above, including version increase + changelog. PTAL. @devoncarew I don't have permission to merge here, so please do it if you're both happy.

@devoncarew devoncarew merged commit 007acf0 into dart-archive:master Apr 23, 2019
Copy link

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

/// for the VM service.
///
/// If the URI is already a VM Service WebSocket URI it will not be modified.
Uri getVmWsUriFromObservatoryUri(Uri uri) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: we may rename this to something like convertToWebSocketUrl({@required String serviceProtocolUrl}).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

4 participants