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

[SchemaRegistry] Fix broken test recordings #14935

Merged
merged 6 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,21 @@ private SchemaRegistryClient CreateClient() =>
Recording.InstrumentClientOptions(new SchemaRegistryClientOptions())
));

private const string SchemaContent = "{\"type\" : \"record\",\"namespace\" : \"TestSchema\",\"name\" : \"Employee\",\"fields\" : [{ \"name\" : \"Name\" , \"type\" : \"string\" },{ \"name\" : \"Age\", \"type\" : \"int\" }]}";

[Test]
public async Task CanRegisterSchema()
{
var client = CreateClient();
var schemaName = "test1";
var groupName = "miyanni_srgroup";
var schemaType = SerializationType.Avro;
var schema = @"
{
""type"" : ""record"",
""namespace"" : ""TestSchema"",
""name"" : ""Employee"",
""fields"" : [
{ ""name"" : ""Name"" , ""type"" : ""string"" },
{ ""name"" : ""Age"", ""type"" : ""int"" }
]
}";

var schemaProperties = await client.RegisterSchemaAsync(groupName, schemaName, schemaType, schema);
var schemaProperties = await client.RegisterSchemaAsync(groupName, schemaName, schemaType, SchemaContent);
Assert.IsNotNull(schemaProperties.Value);
Assert.IsNotNull(schemaProperties.Value.Id);
Assert.IsTrue(Guid.TryParse(schemaProperties.Value.Id, out Guid _));
Assert.AreEqual(schema, schemaProperties.Value.Content);
Assert.AreEqual(SchemaContent, schemaProperties.Value.Content);
}


Expand All @@ -55,23 +47,13 @@ public async Task CanGetSchemaId()
var schemaName = "test1";
var groupName = "miyanni_srgroup";
var schemaType = SerializationType.Avro;
var schema = @"
{
""type"" : ""record"",
""namespace"" : ""TestSchema"",
""name"" : ""Employee"",
""fields"" : [
{ ""name"" : ""Name"" , ""type"" : ""string"" },
{ ""name"" : ""Age"", ""type"" : ""int"" }
]
}";

await client.RegisterSchemaAsync(groupName, schemaName, schemaType, schema);
var schemaProperties = await client.GetSchemaIdAsync(groupName, schemaName, schemaType, schema);
await client.RegisterSchemaAsync(groupName, schemaName, schemaType, SchemaContent);
var schemaProperties = await client.GetSchemaIdAsync(groupName, schemaName, schemaType, SchemaContent);
Assert.IsNotNull(schemaProperties.Value);
Assert.IsNotNull(schemaProperties.Value.Id);
Assert.IsTrue(Guid.TryParse(schemaProperties.Value.Id, out Guid _));
Assert.AreEqual(schema, schemaProperties.Value.Content);
Assert.AreEqual(SchemaContent, schemaProperties.Value.Content);
}

[Test]
Expand All @@ -81,26 +63,16 @@ public async Task CanGetSchema()
var schemaName = "test1";
var groupName = "miyanni_srgroup";
var schemaType = SerializationType.Avro;
var schema = @"
{
""type"" : ""record"",
""namespace"" : ""TestSchema"",
""name"" : ""Employee"",
""fields"" : [
{ ""name"" : ""Name"" , ""type"" : ""string"" },
{ ""name"" : ""Age"", ""type"" : ""int"" }
]
}";

var registerProperties = await client.RegisterSchemaAsync(groupName, schemaName, schemaType, schema);
var registerProperties = await client.RegisterSchemaAsync(groupName, schemaName, schemaType, SchemaContent);
Assert.IsNotNull(registerProperties.Value.Id);
Assert.IsTrue(Guid.TryParse(registerProperties.Value.Id, out Guid _));

var schemaProperties = await client.GetSchemaAsync(registerProperties.Value.Id);
Assert.IsNotNull(schemaProperties.Value);
Assert.IsNotNull(schemaProperties.Value.Id);
Assert.IsTrue(Guid.TryParse(schemaProperties.Value.Id, out Guid _));
Assert.AreEqual(schema, schemaProperties.Value.Content);
Assert.AreEqual(SchemaContent, schemaProperties.Value.Content);
}
}
}

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.

Loading