Skip to content

Commit

Permalink
[Schema Registry] Add a whitespace in schema test case (Azure#16964)
Browse files Browse the repository at this point in the history
* [Schema Registry] Add a whitespace in schema test case

* add recordings

* remove only

* address feedback
  • Loading branch information
deyaaeldeen authored and ckairen committed Aug 24, 2021
1 parent bdc6b88 commit 6214d90
Show file tree
Hide file tree
Showing 3 changed files with 294 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions sdk/schemaregistry/schema-registry/test/schemaRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,52 @@ describe("SchemaRegistryClient", function() {
assertIsValidSchemaId(foundIdSecondCall);
assert.equal(foundIdSecondCall?.id, registered.id);
});

it("schema with whitespace", async () => {
const schema2 = {
name: "azsdk_js_test2",
group: testEnv.SCHEMA_REGISTRY_GROUP,
serializationType: "avro",
content:
"{\n" +
' "type": "record",\n' +
' "name": "Test",\n' +
' "fields": [{ "name": "X", "type": { "type": "string" } }]\n' +
"}\n"
};
// content that is going to the service has whitespaces
const registered = await client.registerSchema(schema2, options);
assertIsValidSchemaId(registered);

const foundSchema = await client.getSchemaById(registered.id, {
onResponse: () => {
assert.fail("Unexpected call to the service");
}
});
assertIsValidSchemaId(foundSchema);
assert.equal(foundSchema.content, schema2.content);

let ran = false;
const foundId = await client.getSchemaId(
{
// content that comes from the service does not have whitespaces
content: foundSchema.content,
group: schema2.group,
name: schema2.name,
serializationType: foundSchema.serializationType
},
{
onResponse: () => {
ran = true;
}
}
);
// the schema comes from the service normalized so that its content has no whitespace
// which is different from the original schema that was registered first and lives
// in the cache. There is a trade-off between the perf hit for doing client-side
// normalization and the perf hit for doing an extra call to the service for the
// normalized one.
assert.isTrue(ran, "Expected call to the service did not happen");
assertIsValidSchemaId(foundId);
});
});

0 comments on commit 6214d90

Please sign in to comment.