-
-
Notifications
You must be signed in to change notification settings - Fork 508
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
Fixes #1420 Models: Tests for event_model.dart #1452
Fixes #1420 Models: Tests for event_model.dart #1452
Conversation
2736289
to
c5fda49
Compare
Please fix the failing tests. Merge with upstream. |
@noman2002 @palisadoes please review. |
merged |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## develop #1452 +/- ##
===========================================
+ Coverage 71.85% 72.26% +0.41%
===========================================
Files 146 146
Lines 7212 7212
===========================================
+ Hits 5182 5212 +30
+ Misses 2030 2000 -30
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@noman2002 please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need to add userinfo.hive and userinfo.lock
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:talawa/models/chats/chat_message.dart'; | ||
import 'package:talawa/models/chats/chat_user.dart'; | ||
|
||
final chatUserOne = | ||
ChatUser(firstName: 'Ravidi', id: '1', image: "https://testimg.com"); | ||
final chatUserTwo = | ||
ChatUser(firstName: 'Sheikh', id: '2', image: "https://testimg.com"); | ||
void main() { | ||
group("Tests for ChatMessage.dart", () { | ||
test('check if ChatMessage JSON serialization works', () { | ||
final message = | ||
ChatMessage('1', chatUserOne, 'Hello, how are you?', chatUserTwo); | ||
|
||
final messageJson = message.toJson(); | ||
|
||
final messageFromJson = ChatMessage.fromJson(messageJson); | ||
|
||
expect(messageFromJson.id, message.id); | ||
expect(messageFromJson.sender!.firstName, message.sender!.firstName); | ||
expect(messageFromJson.receiver!.id, message.receiver!.id); | ||
expect(messageFromJson.messageContent, message.messageContent); | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you have deleted this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think i did it by mistake
looking into it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
their are two folder in model chat
and chats
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move all file of chat into chats
@noman2002
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why there are two folders. I guess their must be some purpose for it. Let it be for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
what about these files ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore chat_message_test.dart
done |
it is produced by this test test/model_tests/user/user_info_test.dart (I am not the author) |
Okay got. I'll update it. No issues. |
|
@noman2002 is the PR okay?
I'll look into 1st option and came back to you |
Thanks. Many languages have packages that allow you to create temporary files independent of the OS. Many times you can add the |
|
@@ -185,7 +185,7 @@ void main() { | |||
|
|||
test('Check if Hive storage works', () async { | |||
Hive | |||
..init("./data") | |||
..init("./temporaryPath") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously it was storing in seprate folder named data and now it will store it in ./temporaryPath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't be a valid path for a Windows based developer. Any other suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@palisadoes @noman2002 I checked on my Windows machine and it was working
This method of storing hive file is used by other test also
for example
talawa/test/widget_tests/after_auth_screens/app_settings/app_setting_page_test.dart
Lines 92 to 99 in 76f1553
final Directory dir = Directory('temporaryPath'); | |
Hive | |
..init(dir.path) | |
..registerAdapter(UserAdapter()) | |
..registerAdapter(OrgInfoAdapter()); | |
await Hive.openBox<User>('currentUser'); | |
await Hive.openBox<OrgInfo>('currentOrg'); | |
await Hive.openBox('url'); |
and
talawa/test/widget_tests/after_auth_screens/profile/edit_profile_page_test.dart
Lines 79 to 86 in 76f1553
final Directory dir = Directory('temporaryPath'); | |
Hive | |
..init(dir.path) | |
..registerAdapter(UserAdapter()) | |
..registerAdapter(OrgInfoAdapter()); | |
await Hive.openBox<User>('currentUser'); | |
await Hive.openBox<OrgInfo>('currentOrg'); | |
await Hive.openBox('url'); |
or I am not able to understand what you want to say. We are just making a file named temporaryPath. I think you misunderstood temporaryPath by /temp file provided in linux systems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so we are using Hive to temporarily store data for testing, but in the lib/
directory. Should we create a test specific const for this for consistency? Like in here https://github.com/PalisadoesFoundation/talawa/tree/develop/test/helpers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we can do something like this for consistency, maybe write all the hive init in one file and call them according to their requirement, instead of initialising Hive in each test case separately.
It will make our code more DRY.
@palisadoes @noman2002
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you like this idea, I'll like to complete this. maybe in this PR or or in separate issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix it in this PR
865b0ff
to
3f0de6f
Compare
3e54b60
to
ba8c459
Compare
@noman2002 @palisadoes why is test failing?? Can you help?? |
@noman2002 is it a new problem or I did something wrong?? |
Codecov problem. It happens. |
@noman2002 Please review and merge if OK. CodeCov regenerated. I have noticed that when CodeCov fails, you have to delete the previous CodeCov comment an rerun the action. |
@noman2002 please review |
@noman2002 do I need to change something?? |
What kind of change does this PR introduce?
It contains the test for event_model.dart
Issue Number:
Fixes #1420
Did you add tests for your changes?
YES
Summary
It contains the test for event_model.dart
Does this PR introduce a breaking change?
NO
Have you read the contributing guide?
YES