Skip to content

Unittest for User Model #15

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

Merged
merged 4 commits into from
Nov 10, 2024
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
35 changes: 35 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Flutter Build And Test
on:
push:
branches:
- main
- unittest
pull_request:
branches:
- main
jobs:
build:
name: Analyze and Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/[email protected]
with:
flutter-version: 3.24.4
channel: stable
- name: Setup Dart
uses: dart-lang/[email protected]
with:
dart-version: 3.5.4
- name: Install dependencies
run: flutter pub get
- name: Analyze
run: flutter analyze
- name: Run tests
run: flutter test
# - name: Build APK
# run: flutter build apk --release --target lib/main/main_prod.dart
# - name: Build Android App Bundle
# run: flutter build appbundle --release --target lib/main/main_prod.dart
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ migrate_working_dir/
*.iws
.idea/

.vscode/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
Expand Down
8 changes: 4 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ if (flutterVersionName == null) {
}

android {
namespace "com.cevheri.flutter.flutter_bloc_advance"
compileSdkVersion 34
ndkVersion flutter.ndkVersion
namespace = "com.cevheri.flutter.flutter_bloc_advance"
compileSdkVersion = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = JavaVersion.VERSION_1_8
}

sourceSets {
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = "1.9.20"
ext.kotlin_version = "1.8.22"
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.android.tools.build:gradle:8.7.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
2 changes: 2 additions & 0 deletions lib/data/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class User extends Equatable {
// @JsonProperty(name: 'phoneNumber')
// final String? phoneNumber;

//Constructor
const User({
this.id,
this.login,
Expand All @@ -63,6 +64,7 @@ class User extends Equatable {
// this.phoneNumber,
});

/// CopyWith method to create a new instance of the User class with new values
User copyWith({
String? id,
String? login,
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion lib/presentation/screen/register/bloc/register_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RegisterBloc extends Bloc<RegisterEvent, RegisterState> {
FutureOr<void> _onSubmit(RegisterEmailChanged event, Emitter<RegisterState> emit) async {
emit(RegisterInitialState());
try {
var resultStatusCode = await _accountRepository.register(event.createUser);
await _accountRepository.register(event.createUser);
emit(RegisterCompletedState());
} catch (e) {
emit(const RegisterErrorState(message: "Register Error"));
Expand Down
112 changes: 112 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.5"
bloc_test:
dependency: "direct dev"
description:
name: bloc_test
sha256: "165a6ec950d9252ebe36dc5335f2e6eb13055f33d56db0eeb7642768849b43d2"
url: "https://pub.dev"
source: hosted
version: "9.1.7"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -214,6 +222,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.2"
coverage:
dependency: transitive
description:
name: coverage
sha256: "88b0fddbe4c92910fefc09cc0248f5e7f0cd23e450ded4c28f16ab8ee8f83268"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -270,6 +286,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
diff_match_patch:
dependency: transitive
description:
name: diff_match_patch
sha256: "2efc9e6e8f449d0abe15be240e2c2a3bcd977c8d126cfd70598aee60af35c0a4"
url: "https://pub.dev"
source: hosted
version: "0.4.1"
dio:
dependency: transitive
description:
Expand Down Expand Up @@ -674,6 +698,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.0"
mockito:
dependency: "direct dev"
description:
name: mockito
sha256: "6841eed20a7befac0ce07df8116c8b8233ed1f4486a7647c7fc5a02ae6163917"
url: "https://pub.dev"
source: hosted
version: "5.4.4"
mocktail:
dependency: transitive
description:
name: mocktail
sha256: "890df3f9688106f25755f26b1c60589a92b3ab91a22b8b224947ad041bf172d8"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
modbus_client:
dependency: transitive
description:
Expand All @@ -698,6 +738,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
Expand Down Expand Up @@ -938,6 +986,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3
url: "https://pub.dev"
source: hosted
version: "1.1.3"
shelf_web_socket:
dependency: transitive
description:
Expand All @@ -951,6 +1015,30 @@ packages:
description: flutter
source: sdk
version: "0.0.99"
source_gen:
dependency: transitive
description:
name: source_gen
sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832"
url: "https://pub.dev"
source: hosted
version: "1.5.0"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b
url: "https://pub.dev"
source: hosted
version: "2.1.2"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
Expand Down Expand Up @@ -1015,6 +1103,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e"
url: "https://pub.dev"
source: hosted
version: "1.25.7"
test_api:
dependency: transitive
description:
Expand All @@ -1023,6 +1119,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.2"
test_core:
dependency: transitive
description:
name: test_core
sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696"
url: "https://pub.dev"
source: hosted
version: "0.6.4"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -1087,6 +1191,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.1"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
xdg_directories:
dependency: transitive
description:
Expand Down
4 changes: 4 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ dev_dependencies:
sdk: flutter
flutter_lints: ^5.0.0
build_runner:
test: ^1.25.7
bloc_test: ^9.1.7
mockito: ^5.4.4



flutter_secure_storage:
Expand Down
Loading
Loading