-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dns property from compose file (#2055)
* 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]>
- Loading branch information
1 parent
45d501b
commit 3ecda3b
Showing
5 changed files
with
177 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import "mocha"; | ||
import { expect } from "chai"; | ||
import { ComposeEditor } from "../../src/index.js"; | ||
import { Compose } from "@dappnode/types"; | ||
|
||
describe("ComposeServiceEditor", function () { | ||
describe("removeDns()", function () { | ||
it("should remove the dns field from the service", function () { | ||
// Create a mock compose object | ||
const mockCompose: Compose = { | ||
version: "3", | ||
services: { | ||
myservice: { | ||
image: "myimage", | ||
dns: "8.8.8.8", | ||
environment: [] | ||
} | ||
} | ||
}; | ||
|
||
// Create a ComposeEditor instance with the mock compose | ||
const composeEditor = new ComposeEditor(mockCompose); | ||
|
||
// Get the service editor for 'myservice' | ||
const serviceEditor = composeEditor.services()["myservice"]; | ||
|
||
// Ensure dns field is present before removal | ||
expect(serviceEditor.get().dns).to.deep.equal("8.8.8.8"); | ||
|
||
// Call removeDns() | ||
serviceEditor.removeDns(); | ||
|
||
// Get the updated service | ||
const updatedService = serviceEditor.get(); | ||
|
||
// Verify that the dns field is removed | ||
expect(updatedService.dns).to.be.undefined; | ||
|
||
// Output the compose and check that dns is not present | ||
const outputCompose = composeEditor.output(); | ||
expect(outputCompose.services["myservice"].dns).to.be.undefined; | ||
|
||
// Ensure other fields remain unchanged | ||
expect(outputCompose.services["myservice"].image).to.equal("myimage"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.