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

add deletedns unit test #2057

Merged

Conversation

Marketen
Copy link
Contributor

@Marketen Marketen commented Nov 8, 2024

The current edit() method merges the original service object with the partial updates returned by serviceEditor(service). Merging { ...service, ...updatedFields } doesn't remove properties from service unless they are explicitly overwritten. Properties that aren't included in updatedFields remain in the merged object.

private edit(serviceEditor: (service: ComposeService) => Partial<ComposeService>): void {
    const service = this.parent.compose.services[this.serviceName];
    this.parent.compose.services[this.serviceName] = {
      ...service,
      ...serviceEditor(service)
    };
}

This is why this implementation of removeDns() doesnt work

removeDns(): void {
    this.edit((service) => {
      if (!service.dns) return service;
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
      const { dns, ...rest } = service;
      return rest;
    });
  }

and this one (that deletes the dns directly without passing through edit()) does:

  removeDns(): void {
    const service = this.get();
    if ('dns' in service) {
      delete service.dns;
    }
}  

@Marketen Marketen requested a review from a team as a code owner November 8, 2024 14:09
@github-actions github-actions bot temporarily deployed to commit November 8, 2024 14:11 Inactive
Copy link

github-actions bot commented Nov 8, 2024

@github-actions github-actions bot temporarily deployed to commit November 8, 2024 14:32 Inactive
Copy link

github-actions bot commented Nov 8, 2024

Dappnode bot has built and pinned the built packages to an IPFS node, for commit: 11aab0f

This is a development version and should only be installed for testing purposes.

  1. Package dappmanager.dnp.dappnode.eth

Install link

Hash: /ipfs/QmcVbknaH8w5qX22qzw7CqzKc1EpdYH46KkAzY2dBFPYWg

(by dappnodebot/build-action)

@github-actions github-actions bot temporarily deployed to commit November 11, 2024 08:02 Inactive
@github-actions github-actions bot temporarily deployed to commit November 11, 2024 08:07 Inactive
@pablomendezroyo pablomendezroyo merged commit 0cb21ad into pablo/remove-dns-property Nov 11, 2024
7 checks passed
@pablomendezroyo pablomendezroyo deleted the marc/add-unit-test-to-delete-dns branch November 11, 2024 08:10
pablomendezroyo added a commit that referenced this pull request Nov 11, 2024
* Remove dns property from compose file

* check has own property

* Force dns removal action before adding aliases

* add logging for debugging

* use dns in

* use internal funcion

* Use aggregate error

* use promise settled

* use custom error class

* add deletedns unit test (#2057)

* add deletedns unit test

* fix removeDns()

* use double quotes

* fix editor with lint

---------

Co-authored-by: pablomendezroyo <[email protected]>

* replace probkematic tag

---------

Co-authored-by: Marc Font <[email protected]>
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.

2 participants