-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(cli): checking request ID is included in outgoing calls
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { describe, test, expect } from 'vitest'; | ||
import { Command } from 'commander'; | ||
import { Response, WhoAmIResponse } from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb'; | ||
import type { Interceptor } from '@connectrpc/connect'; | ||
import { CreateClient } from '../src/core/client/client.js'; | ||
import WhoAmI from '../src/commands/auth/commands/whoami.js'; | ||
import { config } from '../src/core/config.js'; | ||
|
||
|
||
const interceptor = (req) => { | ||
expect(req.header.get('x-request-id'), "must be a valid UUID").toMatch(/^[\da-f]{8}-[\da-f]{4}-[0-5][\da-f]{3}-[089ab][\da-f]{3}-[\da-f]{12}$/i); | ||
|
||
return { | ||
message: new WhoAmIResponse({ | ||
response: new Response( { code: 0, details: 'OK' } ) | ||
}) | ||
}; | ||
}; | ||
|
||
describe('Schema Command', () => { | ||
test('Check subgraph schema', async () => { | ||
const client = CreateClient({ | ||
baseUrl: config.baseURL, | ||
apiKey: config.apiKey, | ||
interceptors: [(next) => interceptor] | ||
}); | ||
|
||
const program = new Command(); | ||
|
||
await program.addCommand( | ||
WhoAmI({ | ||
client, | ||
}), | ||
).parseAsync(['whoami'], { | ||
from: 'user', | ||
}); | ||
}); | ||
}); | ||
|