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

[Schema Registry] Add a whitespace in schema test case #16964

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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);
});
});