test(registry): lib to start and stop an npm-registry-couchapp
This commit is contained in:
		
							parent
							
								
									4093bb2dbe
								
							
						
					
					
						commit
						32c1dcf75b
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -9,3 +9,4 @@ node_modules | |||||||
| 
 | 
 | ||||||
| # build-artifacts | # build-artifacts | ||||||
| dist | dist | ||||||
|  | test/registry/couchdb.* | ||||||
|  | |||||||
| @ -29,6 +29,7 @@ | |||||||
|     "mkdirp": "^0.5.1", |     "mkdirp": "^0.5.1", | ||||||
|     "nock": "^2.5.0", |     "nock": "^2.5.0", | ||||||
|     "nyc": "^2.3.0", |     "nyc": "^2.3.0", | ||||||
|  |     "npm-registry-couchapp": "^2.6.11", | ||||||
|     "proxyquire": "^1.5.0", |     "proxyquire": "^1.5.0", | ||||||
|     "rimraf": "^2.4.0", |     "rimraf": "^2.4.0", | ||||||
|     "standard": "^4.2.1", |     "standard": "^4.2.1", | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								test/registry/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								test/registry/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | |||||||
|  | const { exec } = require('child_process') | ||||||
|  | const { join } = require('path') | ||||||
|  | 
 | ||||||
|  | const opts = { | ||||||
|  |   cwd: join(__dirname, '../../test/registry') | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | module.exports = { | ||||||
|  |   start: exec.bind(null, './start.sh', opts), | ||||||
|  |   stop: exec.bind(null, './stop.sh', opts), | ||||||
|  |   uri: 'http://localhost:5984/registry/_design/app/_rewrite/' | ||||||
|  | } | ||||||
							
								
								
									
										16
									
								
								test/registry/local.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								test/registry/local.ini
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | |||||||
|  | [couch_httpd_auth] | ||||||
|  | public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev | ||||||
|  | users_db_public = true | ||||||
|  | 
 | ||||||
|  | [httpd] | ||||||
|  | bind_address = 0.0.0.0 | ||||||
|  | secure_rewrites = false | ||||||
|  | 
 | ||||||
|  | [couchdb] | ||||||
|  | delayed_commits = false | ||||||
|  | 
 | ||||||
|  | [admins] | ||||||
|  | admin = -pbkdf2-89582b49cd2e8443e29a841f5a76d367956a8e58,1afa2f1531a17ac97f2ac9e334293753,10 | ||||||
|  | 
 | ||||||
|  | [log] | ||||||
|  | level = none | ||||||
							
								
								
									
										25
									
								
								test/registry/start.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								test/registry/start.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,25 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | 
 | ||||||
|  | # exit if an error occurs | ||||||
|  | set -e | ||||||
|  | 
 | ||||||
|  | cd $(dirname $0) | ||||||
|  | 
 | ||||||
|  | # start couchdb as a background process, reset config, load local config | ||||||
|  | couchdb -b -a local.ini | ||||||
|  | 
 | ||||||
|  | COUCH=http://admin:password@127.0.0.1:5984 | ||||||
|  | 
 | ||||||
|  | # create "registry" database | ||||||
|  | curl -X PUT $COUCH/registry | ||||||
|  | 
 | ||||||
|  | # create sample npm user | ||||||
|  | curl -X PUT $COUCH/_users/org.couchdb.user:integration -H Content-Type:application/json --data-binary '{"_id": "org.couchdb.user:integration","name": "integration","roles": [],"type": "user","password": "suchsecure","email": "integration@test.com"}' | ||||||
|  | 
 | ||||||
|  | # npm-registry-couchpp needs this variable set to run | ||||||
|  | export DEPLOY_VERSION=nope | ||||||
|  | 
 | ||||||
|  | # setup npm-registry-couchapp | ||||||
|  | npm explore npm-registry-couchapp -- npm start --npm-registry-couchapp:couch=$COUCH/registry | ||||||
|  | npm explore npm-registry-couchapp -- npm run load --npm-registry-couchapp:couch=$COUCH/registry | ||||||
|  | npm explore npm-registry-couchapp -- NO_PROMPT=yes npm run copy --npm-registry-couchapp:couch=$COUCH/registry | ||||||
							
								
								
									
										10
									
								
								test/registry/stop.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								test/registry/stop.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | 
 | ||||||
|  | # delete "registry" database | ||||||
|  | curl -X DELETE http://admin:password@127.0.0.1:5984/registry | ||||||
|  | 
 | ||||||
|  | # delete "_users" database | ||||||
|  | curl -X DELETE http://admin:password@127.0.0.1:5984/_users | ||||||
|  | 
 | ||||||
|  | # close couchdb background process | ||||||
|  | couchdb -d | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user