- 
                Notifications
    
You must be signed in to change notification settings  - Fork 985
 
Emulator Idempotency: Database #8769
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 14 commits
      Commits
    
    
            Show all changes
          
          
            16 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      45f5d19
              
                iTest start
              
              
                DellaBitta 7c89fcf
              
                Update RepoInfo.ts
              
              
                DellaBitta 0eeac0b
              
                Update Database.ts part 1
              
              
                DellaBitta f5a0cd8
              
                Update Database.ts with idempotency logic.
              
              
                DellaBitta b80c569
              
                Try only host and port
              
              
                DellaBitta 1c270b1
              
                Revert file fully
              
              
                DellaBitta 9738a5c
              
                create RepoInfoEmulatorOptions
              
              
                DellaBitta 960a02c
              
                impl back in place
              
              
                DellaBitta ee04817
              
                Format, lint
              
              
                DellaBitta 1084455
              
                Update error string check in compat test.
              
              
                DellaBitta cbaf931
              
                FIREBASE FATAL ERROR: prefix for test
              
              
                DellaBitta a04b531
              
                Update database.test.ts
              
              
                DellaBitta 1eab9b4
              
                Enable integration tests
              
              
                DellaBitta 487483f
              
                Changeset
              
              
                DellaBitta b597a9e
              
                Fix typos in test names.
              
              
                DellaBitta 7bfbec9
              
                wrap series of tests in USE_EMULATOR
              
              
                DellaBitta File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or 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,8 @@ | ||
| --- | ||
| '@firebase/database-compat': patch | ||
| '@firebase/database': patch | ||
| 'firebase': patch | ||
| --- | ||
| 
     | 
||
| Fixed: invoking `connectDatabaseEmulator` multiple times with the same parameters will no longer | ||
| cause an error. Fixes [GitHub Issue #6824](https://github.com/firebase/firebase-js-sdk/issues/6824). | 
  
    
      This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 | 
|---|---|---|
| 
          
            
          
           | 
    @@ -35,6 +35,7 @@ import { | |
| orderByKey | ||
| } from '../../src/api/Reference_impl'; | ||
| import { | ||
| connectDatabaseEmulator, | ||
| getDatabase, | ||
| goOffline, | ||
| goOnline, | ||
| 
        
          
        
         | 
    @@ -46,8 +47,10 @@ import { EventAccumulatorFactory } from '../helpers/EventAccumulator'; | |
| import { | ||
| DATABASE_ADDRESS, | ||
| DATABASE_URL, | ||
| EMULATOR_PORT, | ||
| getFreshRepo, | ||
| getRWRefs, | ||
| USE_EMULATOR, | ||
| waitFor, | ||
| waitUntil, | ||
| writeAndValidate | ||
| 
          
            
          
           | 
    @@ -138,6 +141,43 @@ describe('Database@exp Tests', () => { | |
| unsubscribe(); | ||
| }); | ||
| 
     | 
||
| it('can connected to emulator', async () => { | ||
                
       | 
||
| if (USE_EMULATOR) { | ||
| const db = getDatabase(defaultApp); | ||
| connectDatabaseEmulator(db, 'localhost', parseInt(EMULATOR_PORT, 10)); | ||
| await get(refFromURL(db, `${DATABASE_ADDRESS}/foo/bar`)); | ||
| } | ||
| }); | ||
| it('can chnage emulator config before network operations', async () => { | ||
| if (USE_EMULATOR) { | ||
| const db = getDatabase(defaultApp); | ||
| const port = parseInt(EMULATOR_PORT, 10); | ||
| connectDatabaseEmulator(db, 'localhost', port + 1); | ||
| connectDatabaseEmulator(db, 'localhost', port); | ||
| await get(refFromURL(db, `${DATABASE_ADDRESS}/foo/bar`)); | ||
| } | ||
| }); | ||
| it('can connected to emulator after network operations with same parameters', async () => { | ||
| if (USE_EMULATOR) { | ||
| const db = getDatabase(defaultApp); | ||
| const port = parseInt(EMULATOR_PORT, 10); | ||
| connectDatabaseEmulator(db, 'localhost', port); | ||
| await get(refFromURL(db, `${DATABASE_ADDRESS}/foo/bar`)); | ||
| connectDatabaseEmulator(db, 'localhost', port); | ||
| } | ||
| }); | ||
| it('cannot connect to emulator after network operations with different parameters', async () => { | ||
| if (USE_EMULATOR) { | ||
| const db = getDatabase(defaultApp); | ||
| const port = parseInt(EMULATOR_PORT, 10); | ||
| connectDatabaseEmulator(db, 'localhost', port); | ||
| await get(refFromURL(db, `${DATABASE_ADDRESS}/foo/bar`)); | ||
| expect(() => { | ||
| connectDatabaseEmulator(db, 'localhost', 9001); | ||
| }).to.throw(); | ||
| } | ||
| }); | ||
| 
     | 
||
| it('can properly handle unknown deep merges', async () => { | ||
| // Note: This test requires `testIndex` to be added as an index. | ||
| // Please run `yarn test:setup` to ensure that this gets added. | ||
| 
          
            
          
           | 
    ||
  
    
      This file contains hidden or 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
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.