Skip to content

Commit

Permalink
Allow integration tests on PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyiliev committed Mar 7, 2023
1 parent d232d36 commit 3d9704d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Integration Tests
on:
pull_request:
paths:
- materialize/**
branches:
- main

jobs:
integration:
Expand Down
2 changes: 1 addition & 1 deletion src/dataGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function prepareTopic(topic: string) {
}
}

async function prepareSchema(megaRecord: any, topic: string, registry: string, avroSchemas: any) {
async function prepareSchema(megaRecord: any, topic: any, registry: any, avroSchemas: any) {
alert({
type: `success`,
name: `Registering Avro schema...`,
Expand Down
20 changes: 11 additions & 9 deletions src/schemas/schemaRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { SchemaType } from '@kafkajs/confluent-schema-registry';
import pkg from '@avro/types';
const { Type } = pkg;
import avroTypes from '@avro/types';
const { Type } = avroTypes;
import alert from 'cli-alerts';

function nameHook(): any {
function nameHook() {
let i = 0;
return function(schema: any) {
if (schema.name) {
schema.name = `name${i++}`;
}
// @ts-ignore
return function(schema) {
// @ts-ignore
schema.name = `name${i++}`
}
}

export async function getAvroSchema(topic: string, record: number, debug: boolean = false){
// @ts-ignore
export async function getAvroSchema(topic, record){
// @ts-ignore
let avroSchema = Type.forValue(record,{typeHook: nameHook()}).schema();
avroSchema["name"] = topic
avroSchema["namespace"] = "com.materialize"
Expand Down Expand Up @@ -57,7 +59,7 @@ export async function registerSchema(avroSchema: any, registry: any) {
return schemaId;
}

export async function getAvroEncodedRecord(record: any, registry: any, schema_id: number) {
export async function getAvroEncodedRecord(record: any, registry: any, schema_id: any) {
let encodedRecord = await registry.encode(schema_id, record);
return encodedRecord;
}

0 comments on commit 3d9704d

Please sign in to comment.