nestjs / azure-storage

Azure Storage module for Nest framework (node.js) ☁️
https://nestjs.com
MIT License
87 stars 35 forks source link

tests(azure-storage-service): fix test #148

Closed Tony133 closed 3 years ago

Tony133 commented 3 years ago

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[x] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

This PR, fix test error "should fail upload when File is null"

Tony133 commented 3 years ago

to be evaluated :-)

manekinekko commented 3 years ago

Thank you for this contribution 👍

manekinekko commented 3 years ago

@Tony133 Could you provide more feedback about the reason for this change?

Tony133 commented 3 years ago

Hi @manekinekko, I made this change because I had made another pull this https://github.com/nestjs/azure-storage/pull/144

gave this error in tests:

 FAIL  lib/azure-storage.service.spec.ts
  ● AzureStorageService › should fail upload when File is null

    expect(received).toBe(expected) // Object.is equality

    Expected: "TypeError: Cannot destructure property `buffer` of 'undefined' or 'null'."
    Received: "TypeError: Cannot destructure property 'buffer' of 'file' as it is null."

      123 |       await storage.upload(null);
      124 |     } catch (e) {
    > 125 |       expect(e.toString()).toBe(
          |                            ^
      126 |         "TypeError: Cannot destructure property `buffer` of 'undefined' or 'null'.",
      127 |       );
      128 |     }

which has nothing to do with what I had done, so I tried to see if I could solve it.

The solution at the moment looks like this I hope it will go well.

manekinekko commented 3 years ago

Oh! I see what was the error.

It seems that the error message of the exception that is thrown when a file is null, has changed:

from:

TypeError: Cannot destructure property `buffer` of 'undefined' or 'null'.

To:

TypeError: Cannot destructure property 'buffer' of 'file' as it is null.

I've sent you few changes to make before merging the PR.

jasonpaige commented 3 years ago

Any chance this can get merged so that the build can be fixed please :pray: ? I'm keen to make use of the feature added with https://github.com/nestjs/azure-storage/pull/65 but the build has been broken since it was merged in last year :(