Skip to content

Commit

Permalink
fix: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorwang committed Dec 30, 2024
1 parent fd08801 commit af0331d
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions generator/test/src/generator_test_src.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import 'package:source_gen_test/annotations.dart';
import 'query.pb.dart';

class Resource<T> {}

class MockCallAdapter1<T> extends CallAdapter<Future<T>, Future<Resource<T>>> {
@override
Future<Resource<T>> adapt(Future<T> Function() call) async {
return Resource();
}
}

@ShouldGenerate(
'''
'''
@override
Future<Resource<GenericUser<User>>> getUser() {
return MockCallAdapter1<GenericUser<User>>().adapt(
() => _getUser(),
);
return MockCallAdapter1<GenericUser<User>>().adapt(() => _getUser());
}
''',
contains: true,
Expand All @@ -30,19 +30,20 @@ abstract class TestCallAdapter1 {
}

class Either<L, R> {}
class MockCallAdapter2<T> extends CallAdapter<Future<T>, Future<Either<T, String>>> {

class MockCallAdapter2<T>
extends CallAdapter<Future<T>, Future<Either<T, String>>> {
@override
Future<Either<T, String>> adapt(Future<T> Function() call) async {
return Either();
}
}

@ShouldGenerate(
'''
'''
@override
Future<Either<User, String>> getUser() {
return MockCallAdapter2<User>().adapt(
() => _getUser(),
);
return MockCallAdapter2<User>().adapt(() => _getUser());
}
''',
contains: true,
Expand All @@ -55,19 +56,19 @@ abstract class TestCallAdapter2 {
}

class Flow<T> {}

class MockCallAdapter3<T> extends CallAdapter<Future<T>, Flow<T>> {
@override
Flow<T> adapt(Future<T> Function() call) {
return Flow();
}
}

@ShouldGenerate(
'''
'''
@override
Flow<User> getUser() {
return MockCallAdapter3<User>().adapt(
() => _getUser(),
);
return MockCallAdapter3<User>().adapt(() => _getUser());
}
''',
contains: true,
Expand All @@ -92,7 +93,9 @@ class Config {
final bool shouldReplace;
final Map<String, dynamic> subConfig;
}

enum FileType { mp4, mp3 }

class DummyTypedExtras extends TypedExtras {
const DummyTypedExtras({
required this.id,
Expand Down

0 comments on commit af0331d

Please sign in to comment.