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

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

Closed
2 tasks done
xni06 opened this issue Sep 14, 2022 · 6 comments
Closed
2 tasks done

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

xni06 opened this issue Sep 14, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@xni06
Copy link

xni06 commented Sep 14, 2022

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

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@xni06 xni06 added the bug Something isn't working label Sep 14, 2022
@lohanidamodar
Copy link
Member

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

@Shiba-Kar
Copy link

 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 ?

@xni06
Copy link
Author

xni06 commented Dec 2, 2022

 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

@Shiba-Kar
Copy link

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

@xni06
Copy link
Author

xni06 commented Dec 3, 2022

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

It's the same principle - fake it

@lohanidamodar
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants