|
1 | 1 | import { MongoClient } from 'mongodb';
|
2 | 2 | import { eventually } from './helpers';
|
3 | 3 | import { TestShell } from './test-shell';
|
4 |
| -import { startTestServer } from '../../../testing/integration-testing-hooks'; |
| 4 | +import { |
| 5 | + startTestServer, |
| 6 | + LOCAL_INSTANCE_HOST, |
| 7 | + LOCAL_INSTANCE_PORT |
| 8 | +} from '../../../testing/integration-testing-hooks'; |
5 | 9 |
|
6 | 10 | describe('e2e', function() {
|
7 | 11 | const connectionString = startTestServer();
|
@@ -42,6 +46,57 @@ describe('e2e', function() {
|
42 | 46 | });
|
43 | 47 | });
|
44 | 48 |
|
| 49 | + describe('set db', () => { |
| 50 | + describe('via host:port/test', () => { |
| 51 | + let shell; |
| 52 | + beforeEach(async() => { |
| 53 | + shell = TestShell.start({ args: [`${LOCAL_INSTANCE_HOST}:${LOCAL_INSTANCE_PORT}/testdb1`] }); |
| 54 | + await shell.waitForPrompt(); |
| 55 | + shell.assertNoErrors(); |
| 56 | + }); |
| 57 | + it('db set correctly', async() => { |
| 58 | + await shell.executeLine('db'); |
| 59 | + shell.assertNoErrors(); |
| 60 | + |
| 61 | + await eventually(() => { |
| 62 | + shell.assertContainsOutput('testdb1'); |
| 63 | + }); |
| 64 | + }); |
| 65 | + }); |
| 66 | + describe('via mongodb://uri', () => { |
| 67 | + let shell; |
| 68 | + beforeEach(async() => { |
| 69 | + shell = TestShell.start({ args: [`mongodb://${LOCAL_INSTANCE_HOST}:${LOCAL_INSTANCE_PORT}/testdb2`] }); |
| 70 | + await shell.waitForPrompt(); |
| 71 | + shell.assertNoErrors(); |
| 72 | + }); |
| 73 | + it('db set correctly', async() => { |
| 74 | + await shell.executeLine('db'); |
| 75 | + shell.assertNoErrors(); |
| 76 | + |
| 77 | + await eventually(() => { |
| 78 | + shell.assertContainsOutput('testdb2'); |
| 79 | + }); |
| 80 | + }); |
| 81 | + }); |
| 82 | + describe('legacy db only', () => { |
| 83 | + let shell; |
| 84 | + beforeEach(async() => { |
| 85 | + shell = TestShell.start({ args: ['testdb3', `--port=${LOCAL_INSTANCE_PORT}`] }); |
| 86 | + await shell.waitForPrompt(); |
| 87 | + shell.assertNoErrors(); |
| 88 | + }); |
| 89 | + it('db set correctly', async() => { |
| 90 | + await shell.executeLine('db'); |
| 91 | + shell.assertNoErrors(); |
| 92 | + |
| 93 | + await eventually(() => { |
| 94 | + shell.assertContainsOutput('testdb3'); |
| 95 | + }); |
| 96 | + }); |
| 97 | + }); |
| 98 | + }); |
| 99 | + |
45 | 100 | describe('with connection string', () => {
|
46 | 101 | let db;
|
47 | 102 | let client;
|
@@ -109,6 +164,15 @@ describe('e2e', function() {
|
109 | 164 | shell.assertNoErrors();
|
110 | 165 | });
|
111 | 166 |
|
| 167 | + it('db set correctly', async() => { |
| 168 | + await shell.executeLine('db'); |
| 169 | + shell.assertNoErrors(); |
| 170 | + |
| 171 | + await eventually(() => { |
| 172 | + shell.assertContainsOutput('test'); |
| 173 | + }); |
| 174 | + }); |
| 175 | + |
112 | 176 | it('allows to find documents', async() => {
|
113 | 177 | await shell.writeInputLine(`use ${dbName}`);
|
114 | 178 |
|
|
0 commit comments