sdk-for-flutter
sdk-for-flutter copied to clipboard
🐛 Bug Report: You've forgotten to add unit tests to the repo
👟 Reproduction steps
Look for unit tests...
👍 Expected behavior
Expect to see some unit tests
👎 Actual Behavior
There aren't any unit tests :-(
🎲 Appwrite version
Version 2.0.x
💻 Operating system
MacOS
🧱 Your Environment
No response
👀 Have you spent some time to check if this issue has been raised before?
- [X] I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- [X] I have read the Code of Conduct
@xni06 Thank you for raising the issue. We do welcome the contribution if anyone is interested. However, the unit tests will have to be written in our https://github.com/appwrite/sdk-generator As our SDKs are generated from swagger specs, we need to generate relevant tests using the specs as well. We do plan on adding tests to all our SDKs.
static Future<Profile?> updateProfile(
Account account,
Databases databases,
Profile profile,
) async {
try {
final user = await account.get();
final doc = await databases.createDocument(
databaseId: userDatabaseID,
collectionId: profileCollectionID,
documentId: user.$id,
data: profile.toJson(),
permissions: [Permission.read(Role.users())],
);
return Profile.fromJson(doc.data);
} on AppwriteException catch (e) {
Utils.debLog(e);
return null;
}
}
How can I test this peace of code in the test folder ?
static Future<Profile?> updateProfile( Account account, Databases databases, Profile profile, ) async { try { final user = await account.get(); final doc = await databases.createDocument( databaseId: userDatabaseID, collectionId: profileCollectionID, documentId: user.$id, data: profile.toJson(), permissions: [Permission.read(Role.users())], ); return Profile.fromJson(doc.data); } on AppwriteException catch (e) { Utils.debLog(e); return null; } }
How can I test this peace of code in the test folder ?
Inject the dependencies; use https://pub.dev/packages/fake_cloud_firestore; verify/expect the outcome
@xni06 not working with firebase , I am working with Appwrite Databases
@xni06 not working with firebase , I am working with Appwrite Databases
It's the same principle - fake it
@xni06 We have now added unit tests with our SDK, we have about 73% test coverage.