Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

46 new testcase failing branch #50

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:dairy_app/core/errors/database_exceptions.dart';
import 'package:dairy_app/core/network/network_info.dart';
import 'package:dairy_app/features/auth/core/failures/failures.dart';
import 'package:dairy_app/features/auth/core/validators/email_validator.dart';
import 'package:dairy_app/features/auth/core/validators/password_validator.dart';
import 'package:dairy_app/features/auth/data/datasources/local%20data%20sources/local_data_source_template.dart';
import 'package:dairy_app/features/auth/data/datasources/remote%20data%20sources/remote_data_source_template.dart';
Expand Down Expand Up @@ -35,6 +36,7 @@ void main() {
localDataSource: localDataSource,
networkInfo: networkInfo,
passwordValidator: PasswordValidator(),
emailValidator: EmailValidator(),
);
});

Expand Down Expand Up @@ -166,11 +168,15 @@ void main() {
'should return SignInFailure.passwordDoesNotExists when local data source throws same failure',
() async {
// arrange
when(networkInfo.isConnected).thenAnswer((_) async => true);
when(
localDataSource.signInUser(
email: anyNamed("email"), password: anyNamed("password")),
).thenThrow(SignInFailure.wrongPassword());

when(
remoteDataSource.signInUser(
email: anyNamed("email"), password: anyNamed("password")),
).thenThrow(FirebaseAuthException(code: 'wrong-password'));
// act
var result = await authenticationRepository.signInWithEmailAndPassword(
email: testEmail, password: testPassword);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Mocks generated by Mockito 5.1.0 from annotations
// Mocks generated by Mockito 5.4.2 from annotations
// in dairy_app/test/features/auth/data/repository/authentication_repository_test.dart.
// Do not manually edit this file.

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i4;

import 'package:dairy_app/core/network/network_info.dart' as _i6;
Expand All @@ -22,9 +23,18 @@ import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class

class _FakeLoggedInUserModel_0 extends _i1.Fake
implements _i2.LoggedInUserModel {}
class _FakeLoggedInUserModel_0 extends _i1.SmartFake
implements _i2.LoggedInUserModel {
_FakeLoggedInUserModel_0(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}

/// A class which mocks [IAuthLocalDataSource].
///
Expand All @@ -36,30 +46,152 @@ class MockIAuthLocalDataSource extends _i1.Mock
}

@override
_i4.Future<_i2.LoggedInUserModel> signUpUser(
{dynamic id, String? email, String? password}) =>
_i4.Future<_i2.LoggedInUserModel> signUpUser({
required dynamic id,
required String? email,
required String? password,
}) =>
(super.noSuchMethod(
Invocation.method(
#signUpUser,
[],
{
#id: id,
#email: email,
#password: password,
},
),
returnValue:
_i4.Future<_i2.LoggedInUserModel>.value(_FakeLoggedInUserModel_0(
this,
Invocation.method(
#signUpUser, [], {#id: id, #email: email, #password: password}),
returnValue: Future<_i2.LoggedInUserModel>.value(
_FakeLoggedInUserModel_0())) as _i4
.Future<_i2.LoggedInUserModel>);
#signUpUser,
[],
{
#id: id,
#email: email,
#password: password,
},
),
)),
) as _i4.Future<_i2.LoggedInUserModel>);
@override
_i4.Future<_i2.LoggedInUserModel> signInUser(
{String? email, String? password}) =>
_i4.Future<_i2.LoggedInUserModel> signInUser({
required String? email,
required String? password,
}) =>
(super.noSuchMethod(
Invocation.method(
#signInUser, [], {#email: email, #password: password}),
returnValue: Future<_i2.LoggedInUserModel>.value(
_FakeLoggedInUserModel_0()))
as _i4.Future<_i2.LoggedInUserModel>);
Invocation.method(
#signInUser,
[],
{
#email: email,
#password: password,
},
),
returnValue:
_i4.Future<_i2.LoggedInUserModel>.value(_FakeLoggedInUserModel_0(
this,
Invocation.method(
#signInUser,
[],
{
#email: email,
#password: password,
},
),
)),
) as _i4.Future<_i2.LoggedInUserModel>);
@override
_i4.Future<void> cacheUser({dynamic id, String? email, String? password}) =>
_i4.Future<void> cacheUser({
required dynamic id,
required String? email,
required String? password,
}) =>
(super.noSuchMethod(
Invocation.method(
#cacheUser,
[],
{
#id: id,
#email: email,
#password: password,
},
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
@override
_i4.Future<bool> verifyPassword(
String? userId,
String? password,
) =>
(super.noSuchMethod(
Invocation.method(
#verifyPassword,
[
userId,
password,
],
),
returnValue: _i4.Future<bool>.value(false),
) as _i4.Future<bool>);
@override
_i4.Future<void> updatePassword({
required String? email,
required String? oldPassword,
required String? newPassword,
}) =>
(super.noSuchMethod(
Invocation.method(
#updatePassword,
[],
{
#email: email,
#oldPassword: oldPassword,
#newPassword: newPassword,
},
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
@override
_i4.Future<_i2.LoggedInUserModel> signInDirectly({required String? userId}) =>
(super.noSuchMethod(
Invocation.method(
#signInDirectly,
[],
{#userId: userId},
),
returnValue:
_i4.Future<_i2.LoggedInUserModel>.value(_FakeLoggedInUserModel_0(
this,
Invocation.method(
#cacheUser, [], {#id: id, #email: email, #password: password}),
returnValue: Future<void>.value(),
returnValueForMissingStub: Future<void>.value()) as _i4.Future<void>);
#signInDirectly,
[],
{#userId: userId},
),
)),
) as _i4.Future<_i2.LoggedInUserModel>);
@override
_i4.Future<void> updateEmail({
required String? oldEmail,
required String? password,
required String? newEmail,
}) =>
(super.noSuchMethod(
Invocation.method(
#updateEmail,
[],
{
#oldEmail: oldEmail,
#password: password,
#newEmail: newEmail,
},
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
}

/// A class which mocks [IAuthRemoteDataSource].
Expand All @@ -72,23 +204,107 @@ class MockIAuthRemoteDataSource extends _i1.Mock
}

@override
_i4.Future<_i2.LoggedInUserModel> signUpUser(
{String? email, String? password}) =>
_i4.Future<_i2.LoggedInUserModel> signUpUser({
required String? email,
required String? password,
}) =>
(super.noSuchMethod(
Invocation.method(
#signUpUser,
[],
{
#email: email,
#password: password,
},
),
returnValue:
_i4.Future<_i2.LoggedInUserModel>.value(_FakeLoggedInUserModel_0(
this,
Invocation.method(
#signUpUser,
[],
{
#email: email,
#password: password,
},
),
)),
) as _i4.Future<_i2.LoggedInUserModel>);
@override
_i4.Future<_i2.LoggedInUserModel> signInUser({
required String? email,
required String? password,
}) =>
(super.noSuchMethod(
Invocation.method(
#signInUser,
[],
{
#email: email,
#password: password,
},
),
returnValue:
_i4.Future<_i2.LoggedInUserModel>.value(_FakeLoggedInUserModel_0(
this,
Invocation.method(
#signInUser,
[],
{
#email: email,
#password: password,
},
),
)),
) as _i4.Future<_i2.LoggedInUserModel>);
@override
_i4.Future<void> updatePassword({
required String? email,
required String? oldPassword,
required String? newPassword,
}) =>
(super.noSuchMethod(
Invocation.method(
#updatePassword,
[],
{
#email: email,
#oldPassword: oldPassword,
#newPassword: newPassword,
},
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
@override
_i4.Future<void> submitForgotPasswordEmail(String? forgotPasswordEmail) =>
(super.noSuchMethod(
Invocation.method(
#signUpUser, [], {#email: email, #password: password}),
returnValue: Future<_i2.LoggedInUserModel>.value(
_FakeLoggedInUserModel_0()))
as _i4.Future<_i2.LoggedInUserModel>);
Invocation.method(
#submitForgotPasswordEmail,
[forgotPasswordEmail],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
@override
_i4.Future<_i2.LoggedInUserModel> signInUser(
{String? email, String? password}) =>
_i4.Future<void> updateEmail({
required String? oldEmail,
required String? password,
required String? newEmail,
}) =>
(super.noSuchMethod(
Invocation.method(
#signInUser, [], {#email: email, #password: password}),
returnValue: Future<_i2.LoggedInUserModel>.value(
_FakeLoggedInUserModel_0()))
as _i4.Future<_i2.LoggedInUserModel>);
Invocation.method(
#updateEmail,
[],
{
#oldEmail: oldEmail,
#password: password,
#newEmail: newEmail,
},
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
}

/// A class which mocks [INetworkInfo].
Expand All @@ -100,7 +316,8 @@ class MockINetworkInfo extends _i1.Mock implements _i6.INetworkInfo {
}

@override
_i4.Future<bool> get isConnected =>
(super.noSuchMethod(Invocation.getter(#isConnected),
returnValue: Future<bool>.value(false)) as _i4.Future<bool>);
_i4.Future<bool> get isConnected => (super.noSuchMethod(
Invocation.getter(#isConnected),
returnValue: _i4.Future<bool>.value(false),
) as _i4.Future<bool>);
}
Loading