Skip to content

Commit b675125

Browse files
committed
patch(fix): octo subnet to generate update diff on association changes.
1 parent 7f21d05 commit b675125

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/octo/src/models/subnet/subnet.model.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('Subnet UT', () => {
4343
}).rejects.toThrowErrorMatchingInlineSnapshot('"Change of subnet type is not supported!"');
4444
});
4545

46-
it('should generate add diff of associations when previous does not exist', async () => {
46+
it('should generate update diff of associations on adding subnet', async () => {
4747
const app = new App('test');
4848
const region = new Region('region');
4949
app.addRegion(region);
@@ -58,7 +58,7 @@ describe('Subnet UT', () => {
5858
expect(diff).toMatchInlineSnapshot(`
5959
[
6060
{
61-
"action": "add",
61+
"action": "update",
6262
"field": "association",
6363
"value": "region-subnet1",
6464
},
@@ -81,7 +81,7 @@ describe('Subnet UT', () => {
8181
expect(diff).toMatchInlineSnapshot(`[]`);
8282
});
8383

84-
it('should generate delete diff of associations on removing subnet association', async () => {
84+
it('should generate update diff of associations on removing subnet', async () => {
8585
const app = new App('test');
8686
const region = new Region('region');
8787
app.addRegion(region);
@@ -101,7 +101,7 @@ describe('Subnet UT', () => {
101101
expect(diff).toMatchInlineSnapshot(`
102102
[
103103
{
104-
"action": "delete",
104+
"action": "update",
105105
"field": "association",
106106
"value": "region-subnet1",
107107
},

packages/octo/src/models/subnet/subnet.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ export class Subnet extends AModel<ISubnet, Subnet> {
6262
const previousSiblings = previous?.getSiblings()['subnet'] ?? [];
6363
for (const pd of previousSiblings) {
6464
if (!siblings.find((d) => (d.to as Subnet).subnetId === (pd.to as Subnet).subnetId)) {
65-
diffs.push(new Diff(this, DiffAction.DELETE, 'association', (pd.to as Subnet).subnetId));
65+
diffs.push(new Diff(this, DiffAction.UPDATE, 'association', (pd.to as Subnet).subnetId));
6666
}
6767
}
6868
for (const d of siblings) {
6969
if (!previousSiblings.find((pd) => (pd.to as Subnet).subnetId === (d.to as Subnet).subnetId)) {
70-
diffs.push(new Diff(this, DiffAction.ADD, 'association', (d.to as Subnet).subnetId));
70+
diffs.push(new Diff(this, DiffAction.UPDATE, 'association', (d.to as Subnet).subnetId));
7171
}
7272
}
7373

0 commit comments

Comments
 (0)