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

New command: spo site archive. Closes #6018 #6031

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Saurabh7019
Copy link
Contributor

Closes #6018

@Saurabh7019 Saurabh7019 marked this pull request as ready for review May 6, 2024 14:31
@milanholemans
Copy link
Contributor

Thank you @Saurabh7019! We'll try to review it ASAP!

@milanholemans milanholemans self-assigned this May 12, 2024
Copy link
Contributor

@milanholemans milanholemans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool stuff @Saurabh7019! I made a few comments while reviewing your code. Could you take a look at them, please?

src/m365/spo/commands/site/site-archive.ts Show resolved Hide resolved
src/m365/spo/commands/site/site-archive.ts Outdated Show resolved Hide resolved
src/m365/spo/commands/site/site-archive.ts Outdated Show resolved Hide resolved
src/m365/spo/commands/site/site-archive.ts Outdated Show resolved Hide resolved
src/m365/spo/commands/site/site-archive.ts Outdated Show resolved Hide resolved

it('correctly handles API error', async () => {
sinon.stub(request, 'post').callsFake(async (opts) => {
if ((opts.url as string).indexOf(`/_vti_bin/client.svc/ProcessQuery`) > -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, it's not really needed to check for a URL. Since we just want to test if the message was logged correctfully.
So let's use sinon.stub(request, 'post').rejects({errorObject}).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the URL check from the test. I am using callsFake to resolve with a response that contains an ErrorInfo object to test this part:

        if (response.ErrorInfo) {
          throw response.ErrorInfo.ErrorMessage;
        }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's entirely fine to add a test for this. But in this test we don't really care if we passed the right URL (that's already tested in other tests). In this test we only care that if we catch an error, that it's properly displayed.
Therefore I think we can remove the URL check.

@@ -247,6 +247,7 @@ export default {
SITE_APPPERMISSION_LIST: `${prefix} site apppermission list`,
SITE_APPPERMISSION_REMOVE: `${prefix} site apppermission remove`,
SITE_APPPERMISSION_SET: `${prefix} site apppermission set`,
SITE_ARCHIVE: `${prefix} site archive`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking of it some more, I think this command should be called spo tenant site archive. Let's discuss this on the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I will wait for the discussion to conclude before making this change and marking the PR as ready.

docs/docs/cmd/spo/site/site-archive.mdx Show resolved Hide resolved
docs/docs/cmd/spo/site/site-archive.mdx Outdated Show resolved Hide resolved
docs/docs/cmd/spo/site/site-archive.mdx Show resolved Hide resolved
@milanholemans milanholemans marked this pull request as draft June 12, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New command: spo site archive
2 participants