Skip to content

Commit

Permalink
improve test by testing multiple messages in operation
Browse files Browse the repository at this point in the history
  • Loading branch information
smoya committed Nov 27, 2023
1 parent 6557d78 commit 2e7953c
Showing 1 changed file with 93 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ testRule('asyncapi3-operation-messages-from-referred-channel', [
},
errors: [
{
message:
'Operation message does not belong to the specified channel.',
message: 'Operation message does not belong to the specified channel.',
path: ['operations', 'UserSignedUp', 'messages', '0'],
severity: DiagnosticSeverity.Error,
}
Expand Down Expand Up @@ -224,11 +223,101 @@ testRule('asyncapi3-operation-messages-from-referred-channel', [
},
errors: [
{
message:
'Operation message does not belong to the specified channel.',
message: 'Operation message does not belong to the specified channel.',
path: ['components', 'operations', 'UserSignedUp', 'messages', '0'],
severity: DiagnosticSeverity.Error,
}
],
},
{
name: 'invalid case - multiple messages from operation in components pointing to multiple message from a different channel defined under components',
document: {
asyncapi: '3.0.0',
info: {
title: 'Account Service',
version: '1.0.0'
},
channels: {
UserSignedUp: {
messages: {
UserSignedUp: {
payload: {
type: 'object',
properties: {
displayName: {
type: 'string'
},
email: {
type: 'string'
}
}
}
}
}
}
},
components: {
channels: {
UserRemoved: {
messages: {
UserRemoved: {
payload: {
type: 'object',
properties: {
displayName: {
type: 'string'
},
email: {
type: 'string'
}
}
}
},
UserDeleted: {
payload: {
type: 'object',
properties: {
displayName: {
type: 'string'
},
email: {
type: 'string'
}
}
}
}
}
}
},
operations: {
UserSignedUp: {
action: 'send',
channel: {
$ref: '#/channels/UserSignedUp'
},
messages: [
{
$ref: '#/components/channels/UserRemoved/messages/UserRemoved'
},
{
$ref: '#/components/channels/UserRemoved/messages/UserDeleted'
}
]
}
},
}
},
errors: [
{
message: 'Operation message does not belong to the specified channel.',
path: ['components', 'operations', 'UserSignedUp', 'messages', '0'],
severity: DiagnosticSeverity.Error,
},
{
message: 'Operation message does not belong to the specified channel.',
path: ['components', 'operations', 'UserSignedUp', 'messages', '1'],
severity: DiagnosticSeverity.Error,
}
],
},
]);

0 comments on commit 2e7953c

Please sign in to comment.