Skip to content

Commit

Permalink
make deleted required, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomás Ciccola committed Sep 26, 2023
1 parent 9166171 commit 8ea2c4a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion proto/common/v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ message Common_1 {
google.protobuf.Timestamp updatedAt = 4 [(required) = true];
// 32-byte hash of the discovery key of a core
bytes createdBy = 5 [(required) = true];
optional bool deleted = 6;
bool deleted = 6;
}
/* ignored fields and differences from common.json jsonSchema
* id is a byte buffer here and a string in jsonSchema
Expand Down
6 changes: 3 additions & 3 deletions schema/common/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
},
"deleted": {
"description": "Indicates whether the document has been deleted",
"type": "boolean",
"const": true
"type": "boolean"
}
},
"required": [
Expand All @@ -52,6 +51,7 @@
"updatedAt",
"links",
"versionId",
"createdBy"
"createdBy",
"deleted"
]
}
2 changes: 1 addition & 1 deletion src/lib/decode-conversions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,6 @@ function convertCommon(
createdAt: common.createdAt,
updatedAt: common.updatedAt,
createdBy: common.createdBy.toString('hex'),
deleted: common.deleted || undefined,
deleted: common.deleted,
}
}
17 changes: 1 addition & 16 deletions test/fixtures/bad-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const badDocs = [
attachments: [],
tags: {},
metadata: {},
deleted: false,
},
},
{
Expand All @@ -37,22 +38,6 @@ export const badDocs = [
links: [],
roleId: '',
fromIndex: 4,
},
},
{
text: 'doc with invalid value for `deleted` field',
doc: {
docId: cachedValues.docId,
versionId: cachedValues.versionId,
schemaName: 'observation',
createdAt: cachedValues.createdAt,
updatedAt: cachedValues.updatedAt,
createdBy: cachedValues.createdBy,
links: [],
refs: [],
attachments: [],
tags: {},
metadata: {},
deleted: false,
},
},
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/good-docs-completed.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const goodDocsCompleted = [
networkAvailable: false,
},
},
deleted: false,
},
expected: {},
},
Expand All @@ -86,6 +87,7 @@ export const goodDocsCompleted = [
relation: cachedValues.defaultPresets.point,
},
name: 'myProject',
deleted: false,
},
expected: {},
},
Expand All @@ -110,6 +112,7 @@ export const goodDocsCompleted = [
value: 'somePrimitiveTagValue',
},
],
deleted: false,
},
expected: {},
},
Expand Down Expand Up @@ -137,6 +140,7 @@ export const goodDocsCompleted = [
fieldIds: cachedValues.fieldIds,
iconId: cachedValues.iconId,
terms: ['imastring'],
deleted: false,
},
expected: {},
},
Expand All @@ -151,6 +155,7 @@ export const goodDocsCompleted = [
links: [],
roleId: '6fd029a78243',
fromIndex: 5,
deleted: false,
},
expected: {},
},
Expand All @@ -164,6 +169,7 @@ export const goodDocsCompleted = [
createdBy: cachedValues.createdBy,
links: [],
name: 'my device name',
deleted: false,
},
expected: {},
},
Expand All @@ -189,6 +195,7 @@ export const goodDocsCompleted = [
blobIndex: Buffer.from('blobIndex'),
},
identitySignature: Buffer.from('identity'),
deleted: false,
},
expected: {},
},
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/good-docs-minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const goodDocsMinimal = [
attachments: [],
tags: {},
metadata: {},
deleted: false,
},
expected: {},
},
Expand All @@ -36,6 +37,7 @@ export const goodDocsMinimal = [
updatedAt: cachedValues.updatedAt,
createdBy: cachedValues.createdBy,
links: [],
deleted: false,
},
expected: {},
},
Expand All @@ -51,6 +53,7 @@ export const goodDocsMinimal = [
tagKey: 'myTagKey',
label: 'my label',
type: 'text',
deleted: false,
},
expected: {},
},
Expand All @@ -70,6 +73,7 @@ export const goodDocsMinimal = [
removeTags: {},
fieldIds: [],
terms: [],
deleted: false,
},
expected: {},
},
Expand All @@ -84,6 +88,7 @@ export const goodDocsMinimal = [
links: [],
roleId: '3b0104e370f9',
fromIndex: 5,
deleted: false,
},
expected: {},
},
Expand All @@ -97,6 +102,7 @@ export const goodDocsMinimal = [
createdBy: cachedValues.createdBy,
links: [],
name: 'my device name',
deleted: false,
},
expected: {},
},
Expand All @@ -122,6 +128,7 @@ export const goodDocsMinimal = [
blobIndex: Buffer.from('blobIndex'),
},
identitySignature: Buffer.from('identity'),
deleted: false,
},
expected: {},
},
Expand Down

0 comments on commit 8ea2c4a

Please sign in to comment.