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

bidirectional tests #7

Merged
merged 4 commits into from
Sep 22, 2023
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
1 change: 0 additions & 1 deletion src/target/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export class FileTarget extends Target {

async send(message: Message) {
std.log('file target sending', {message})
await files.createFile(this.options.file)
await files.appendFile(this.options.file, message.toString() + '\n')
std.log('file target sent')
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function loadYAML<T>(file: string) {
}

export async function createFile(file: string) {
const handle = await fs.promises.open(path.resolve(file), 'w+')
const handle = await fs.promises.open(path.resolve(file), 'a+')
await handle.close()
}

Expand Down
12 changes: 6 additions & 6 deletions src/utils/hae.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function exit<T>(fn: (args: T) => Promise<void>): (args: T) => Promise<void> {
return async (options: T) => {
try {
await fn(options)
} catch (e) {
std.log(e)
} catch (error) {
std.log({error})
process.exit(1)
}
}
Expand All @@ -22,17 +22,17 @@ function log<T>(fn: (args: T) => Promise<void>): (args: T) => Promise<void> {
return async (args: T) => {
try {
await fn(args)
} catch (e) {
std.log(e)
} catch (error) {
std.log({error})
}
}
}

async function _try(fn: () => Promise<void>, reason?: string) {
try {
await fn()
} catch (e) {
std.log(reason, e)
} catch (error) {
std.log(reason, {error})
}
}

Expand Down
91 changes: 0 additions & 91 deletions tests/bidirectional/bidirectional.test.ts

This file was deleted.

13 changes: 13 additions & 0 deletions tests/bridge/can.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {createBidirectionalBridgeTest, createBridgeTest} from './utils'

describe('bridge', () => {
createBidirectionalBridgeTest(
'can',
{source: 'can', sourceName: 'can2xBridge'},
{target: 'can', targetName: 'can2xBridge'}
)
})

describe('bridge', () => {
createBridgeTest('can', {source: 'can'}, {target: 'can'})
})
5 changes: 0 additions & 5 deletions tests/bridge/can/can-file.sh

This file was deleted.

64 changes: 0 additions & 64 deletions tests/bridge/can/can.test.ts

This file was deleted.

4 changes: 0 additions & 4 deletions tests/bridge/can/console-can.sh

This file was deleted.

4 changes: 0 additions & 4 deletions tests/bridge/console/send.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import std from '#std'
import * as utils from '#utils'
import {expect} from 'chai'

describe('file', () => {
describe('bridge', () => {
it('file2file', async () => {
const message = Message.fromJSON({id: 69, data: [1, 2, 3], ext: false, rtr: false})

Expand Down
4 changes: 0 additions & 4 deletions tests/bridge/file/send.sh

This file was deleted.

12 changes: 12 additions & 0 deletions tests/bridge/http.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {createBridgeTest} from './utils'

describe('bridge', () => {
createBridgeTest(
'http',
{source: 'http'},
{
target: 'http',
targetEndpoint: 'http://localhost:3000',
}
)
})
40 changes: 0 additions & 40 deletions tests/bridge/http/http.test.ts

This file was deleted.

4 changes: 0 additions & 4 deletions tests/bridge/http/send.sh

This file was deleted.

28 changes: 28 additions & 0 deletions tests/bridge/mqtt.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {createBidirectionalBridgeTest, createBridgeTest} from './utils'

// TODO: mqtt returns to original sender ... (similar but not same bug as at mqtt bus)
describe.skip('bridge', () => {
createBidirectionalBridgeTest(
'mqtt',
{
source: 'mqtt',
},
{
target: 'mqtt',
targetEndpoint: 'mqtt://localhost:3000',
}
)
})

describe('bridge', () => {
createBridgeTest(
'mqtt',
{
source: 'mqtt',
},
{
target: 'mqtt',
targetEndpoint: 'mqtt://localhost:3000',
}
)
})
4 changes: 0 additions & 4 deletions tests/bridge/mqtt/console-mqtt.sh

This file was deleted.

4 changes: 0 additions & 4 deletions tests/bridge/mqtt/mqtt-file.sh

This file was deleted.

40 changes: 0 additions & 40 deletions tests/bridge/mqtt/mqtt.test.ts

This file was deleted.

Loading