sdk-for-flutter icon indicating copy to clipboard operation
sdk-for-flutter copied to clipboard

🐛 Bug Report: You've forgotten to add unit tests to the repo

Open xni06 opened this issue 2 years ago • 1 comments

👟 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?

xni06 avatar Sep 14 '22 13:09 xni06

@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.

lohanidamodar avatar Sep 21 '22 02:09 lohanidamodar

 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 ?

Shiba-Kar avatar Dec 02 '22 17:12 Shiba-Kar

 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 avatar Dec 02 '22 21:12 xni06

@xni06 not working with firebase , I am working with Appwrite Databases

Shiba-Kar avatar Dec 03 '22 06:12 Shiba-Kar

@xni06 not working with firebase , I am working with Appwrite Databases

It's the same principle - fake it

xni06 avatar Dec 03 '22 09:12 xni06

@xni06 We have now added unit tests with our SDK, we have about 73% test coverage.

lohanidamodar avatar Jun 22 '23 00:06 lohanidamodar