change file structure, replace rate_limit with the pub dependency

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-06-03 13:38:32 +05:30
parent eac8093b22
commit d758f3df1d
39 changed files with 126 additions and 448 deletions
+42 -23
View File
@@ -4,6 +4,23 @@ import 'dart:io';
import 'package:stream_chat/stream_chat.dart';
import 'package:stream_chat/version.dart';
import 'package:test/test.dart';
import 'dart:math' as math;
// This alphabet uses `A-Za-z0-9_-` symbols. The genetic algorithm helped
// optimize the gzip compression for this alphabet.
const _alphabet =
'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW';
/// Generates a random String id
/// Adopted from: https://github.com/ai/nanoid/blob/main/non-secure/index.js
String randomId({int size = 21}) {
var id = '';
for (var i = 0; i < size; i++) {
id += _alphabet[(math.Random().nextDouble() * 64).floor() | 0];
}
return id;
}
void prepareTest() {
// https://github.com/flutter/flutter/issues/20907
@@ -15,30 +32,32 @@ void prepareTest() {
void main() {
prepareTest();
test('stream chat version matches pubspec', () async {
/// Create a new instance of [StreamChatClient]
/// by passing the apikey obtained from your project dashboard.
final client = StreamChatClient('b67pax5b2wdq', logLevel: Level.INFO);
print(randomId());
/// Set the current user. In a production scenario, this should be done using
/// a backend to generate a user token using our server SDK.
/// Please see the following for more information:
/// https://getstream.io/chat/docs/ios_user_setup_and_tokens/
await client.connectUser(
User(
id: 'cool-shadow-7',
extraData: {
'image':
'https://getstream.io/random_png/?id=cool-shadow-7&amp;name=Cool+shadow',
},
),
'''eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiY29vbC1zaGFkb3ctNyJ9.gkOlCRb1qgy4joHPaxFwPOdXcGvSPvp6QY0S4mpRkVo''',
);
try {
await client.banUser('asdasdas');
} catch (e) {
print(e);
}
// /// Create a new instance of [StreamChatClient]
// /// by passing the apikey obtained from your project dashboard.
// final client = StreamChatClient('b67pax5b2wdq', logLevel: Level.INFO);
//
// /// Set the current user. In a production scenario, this should be done using
// /// a backend to generate a user token using our server SDK.
// /// Please see the following for more information:
// /// https://getstream.io/chat/docs/ios_user_setup_and_tokens/
// await client.connectUser(
// User(
// id: 'cool-shadow-7',
// extraData: {
// 'image':
// 'https://getstream.io/random_png/?id=cool-shadow-7&amp;name=Cool+shadow',
// },
// ),
// '''eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiY29vbC1zaGFkb3ctNyJ9.gkOlCRb1qgy4joHPaxFwPOdXcGvSPvp6QY0S4mpRkVo''',
// );
//
// try {
// await client.banUser('asdasdas');
// } catch (e) {
// print(e);
// }
// final pubspecPath = '${Directory.current.path}/pubspec.yaml';
// final pubspec = File(pubspecPath).readAsStringSync();