-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update to f78d3cb5fc9194062a8d5f6f058d2dd37d2b9c3a
- Loading branch information
1 parent
bfb3687
commit 1063f9d
Showing
4 changed files
with
104 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import 'package:electric_client/src/auth/auth.dart'; | ||
import 'package:electric_client/src/config/config.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('hydrateConfig adds expected defaults', () { | ||
final hydrated = hydrateConfig( | ||
ElectricConfig( | ||
auth: const AuthConfig( | ||
token: 'test-token', | ||
), | ||
), | ||
); | ||
|
||
expect(hydrated.replication.host, '127.0.0.1'); | ||
expect(hydrated.replication.port, 5133); | ||
expect(hydrated.replication.ssl, false); | ||
|
||
expect(hydrated.auth.token, 'test-token'); | ||
|
||
expect(hydrated.debug, false); | ||
}); | ||
|
||
test('custom config', () { | ||
final hydrated = hydrateConfig( | ||
ElectricConfig( | ||
auth: const AuthConfig( | ||
token: 'test-token-2', | ||
), | ||
url: 'https://192.169.2.10', | ||
debug: true, | ||
), | ||
); | ||
|
||
expect(hydrated.replication.host, '192.169.2.10'); | ||
expect(hydrated.replication.port, 443); | ||
expect(hydrated.replication.ssl, true); | ||
|
||
expect(hydrated.auth.token, 'test-token-2'); | ||
|
||
expect(hydrated.debug, true); | ||
}); | ||
|
||
test('port inference', () { | ||
final httpConfig = hydrateConfig( | ||
ElectricConfig( | ||
auth: const AuthConfig( | ||
token: 'test-token-3', | ||
), | ||
url: 'http://1.1.1.1', | ||
), | ||
); | ||
|
||
expect(httpConfig.replication.port, 80); | ||
expect(httpConfig.replication.ssl, false); | ||
|
||
final httpsConfig = hydrateConfig( | ||
ElectricConfig( | ||
auth: const AuthConfig( | ||
token: 'test-token-3', | ||
), | ||
url: 'https://1.1.1.1', | ||
), | ||
); | ||
|
||
expect(httpsConfig.replication.port, 443); | ||
expect(httpsConfig.replication.ssl, true); | ||
}); | ||
|
||
test('ssl', () { | ||
final httpsConfig = hydrateConfig( | ||
ElectricConfig( | ||
auth: const AuthConfig( | ||
token: 'test-token-3', | ||
), | ||
url: '1.1.1.1?ssl=true', | ||
), | ||
); | ||
|
||
expect(httpsConfig.replication.ssl, true); | ||
}); | ||
} |