-
Notifications
You must be signed in to change notification settings - Fork 6
New replicator config #79
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
base: v1
Are you sure you want to change the base?
Changes from all commits
7624d80
2c7b67c
ad85c51
d31c132
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Couchbase Lite React Native - Test Environment Configuration | ||
| # Copy this file to .env.local and fill in your actual values | ||
| # Note: .env.local is git-ignored for security | ||
|
|
||
| # Sync Gateway Configuration | ||
| EXPO_PUBLIC_SYNC_GATEWAY_URL=wss://your-gateway-url:4984/your-endpoint | ||
| EXPO_PUBLIC_SYNC_USERNAME=your_username | ||
| EXPO_PUBLIC_SYNC_PASSWORD=your_password | ||
|
|
||
| # Note: These credentials are used for testing purposes only | ||
| # Never commit actual credentials to version control |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,8 +14,10 @@ import { | |
| Collection, | ||
| MutableDocument, | ||
| Document, | ||
| ConcurrencyControl | ||
| } from 'cbl-reactnative';import getFileDefaultPath from '@/service/file/getFileDefaultPath'; | ||
| ConcurrencyControl, | ||
| CollectionConfiguration | ||
| } from 'cbl-reactnative'; | ||
| import getFileDefaultPath from '@/service/file/getFileDefaultPath'; | ||
|
|
||
| export default function CustomBugFixScreen() { | ||
| function reset() {} | ||
|
|
@@ -63,22 +65,26 @@ export default function CustomBugFixScreen() { | |
|
|
||
| const connectToSyncGateway = async () => { | ||
| setListOfLogs(prev => [...prev, 'Connecting to Sync Gateway']); // ✅ Use prev | ||
| const defaultCollection = await database?.defaultCollection(); | ||
| if(database === null || database === undefined) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a good suggestion |
||
| throw Error("Database is undefined") | ||
| } | ||
| const defaultCollection = await database.defaultCollection(); | ||
|
|
||
| const syncGatewayUrl = "wss://nasm0fvdr-jnehnb.apps.cloud.couchbase.com:4984/testendpoint" | ||
| const syncGatewayUrl = process.env.EXPO_PUBLIC_SYNC_GATEWAY_URL || "wss://localhost:4984/testendpoint" | ||
| const endpoint = new URLEndpoint(syncGatewayUrl); | ||
| const username = "jayantdhingra" | ||
| const password = "f9yu5QT4B5jpZep@" | ||
| const username = process.env.EXPO_PUBLIC_SYNC_USERNAME || "test_user" | ||
| const password = process.env.EXPO_PUBLIC_SYNC_PASSWORD || "test_pass" | ||
|
|
||
| const replicatorConfig = new ReplicatorConfiguration(endpoint) | ||
|
|
||
| const collectionConfig = new CollectionConfiguration(defaultCollection) | ||
| const listOfCollectionConfig = [collectionConfig] | ||
|
|
||
| const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig, endpoint) | ||
| replicatorConfig.setAuthenticator(new BasicAuthenticator(username, password)) | ||
| // replicatorConfig.setContinuous(true) | ||
| replicatorConfig.setAcceptOnlySelfSignedCerts(false); | ||
|
|
||
|
|
||
| if (defaultCollection) { | ||
| replicatorConfig.addCollection(defaultCollection) | ||
| } | ||
|
|
||
| const replicator = await Replicator.create(replicatorConfig) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import React from 'react'; | ||
| import TestRunnerContainer from '@/components/TestRunnerContainer/TestRunnerContainer'; | ||
|
|
||
| import { ReplicatorNewApiTests } from '../../cblite-js-tests/cblite-tests/e2e/replicator-new-api-test'; | ||
|
|
||
| export default function TestsReplicatorScreen() { | ||
| function reset() {} | ||
|
|
||
| async function update(): Promise<string[]> { | ||
| try { | ||
| return ['']; | ||
| } catch (e) { | ||
| const errorMessage = e instanceof Error ? e.message : String(e); | ||
| return [errorMessage]; | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <TestRunnerContainer | ||
| navigationTitle="Replicator Tests" | ||
| subTitle="Run Sync Gate before tests - visit tests README.md" | ||
| testCases={[ReplicatorNewApiTests]} | ||
| /> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { | |||||||||||||||||||||
| URLEndpoint, | ||||||||||||||||||||||
| BasicAuthenticator, | ||||||||||||||||||||||
| MutableDocument, | ||||||||||||||||||||||
| CollectionConfiguration, | ||||||||||||||||||||||
| ListenerToken | ||||||||||||||||||||||
| } from 'cbl-reactnative'; | ||||||||||||||||||||||
| import getFileDefaultPath from '@/service/file/getFileDefaultPath'; | ||||||||||||||||||||||
|
|
@@ -62,12 +63,18 @@ export default function ReplicatorListenersScreen() { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const endpoint = new URLEndpoint(SYNC_GATEWAY_URL); | ||||||||||||||||||||||
| const replicatorConfig = new ReplicatorConfiguration(endpoint); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| //Create CollectionConfiguration | ||||||||||||||||||||||
| const collectionConfig = new CollectionConfiguration(defaultCollection); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const listOfCollectionConfig = [collectionConfig] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Pass array of configs and endpoint to constructor | ||||||||||||||||||||||
| const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig , endpoint); | ||||||||||||||||||||||
|
Comment on lines
+67
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comments explaining the API change can be removed as the code is now straightforward. Also, there are extra blank lines and an extra space in the constructor call that can be cleaned up for better readability.
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| replicatorConfig.setAuthenticator(new BasicAuthenticator(USERNAME, PASSWORD)); | ||||||||||||||||||||||
| replicatorConfig.setContinuous(true); | ||||||||||||||||||||||
| replicatorConfig.setAcceptOnlySelfSignedCerts(false); | ||||||||||||||||||||||
| replicatorConfig.addCollection(defaultCollection); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const replicator = await Replicator.create(replicatorConfig); | ||||||||||||||||||||||
| setReplicator(replicator); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is using CBL 3.3, we were using kotlin 1.9.24