Skip to content

Commit

Permalink
move require('../lib/redis_conf.js') inside lab.test() to ensure its …
Browse files Browse the repository at this point in the history
…only required once test is running as suggested hapijs/lab#401 (comment)
  • Loading branch information
nelsonic committed Jul 10, 2015
1 parent 7a4573b commit 8b4a1df
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,31 @@ We use:
+ **n** for the **name** of the person who wrote the message
+ **t** for the **timestamp** the message was *received* by the node server (_to avoid time-zone issues_);

## Run it!
# Run it!

## Locally (_on your own mahine_)

Define the TCP `PORT` (_environment variable_) you want the Hapi.js + Socket.io server to listen on:
```sh
export PORT=8000
```
then you can start the app with:
```sh
npm install && npm start
```

## Running the Tests (_Locally_)

To successfully run the tests you need to have an environment variable for RedisCloud
(this is because we like to know that our code works on both "local" and in a "production" enviroment...)

E.g:
```sh
export REDISCLOUD_URL=redis://rediscloud:[email protected]:12345
```

## Heroku (deploying to Heroku)



## Background Reading
Expand Down
1 change: 1 addition & 0 deletions lib/redis_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var url = require('url');
/**** determine if we are connecting to RedisCloud or Local Instance ****/
// console.log('WTF?! - - > process.env.REDISCLOUD_URL '+ process.env.REDISCLOUD_URL);
if(process.env.REDISCLOUD_URL) {
console.log('- - - > HOW IS THIS NOT BEING "COVERED" ??!! when this being console.log(ed) < - - - ')
var redisURL = url.parse(process.env.REDISCLOUD_URL);
var redisconfig = {
port: redisURL.port,
Expand Down
9 changes: 5 additions & 4 deletions test/_redis_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ lab.experiment('RedisCloud Connection Check', { timeout: 10000 }, function () {
// var REDISCLOUD_URL = process.env.REDISCLOUD_URL;
uncache('../lib/redis_config.js');
console.log('- - > process.env.REDISCLOUD_URL '+ process.env.REDISCLOUD_URL);
var rc = require('../lib/redis_config.js');
console.log(rc);
var redisClient = redis.createClient(rc.port, rc.host, {no_ready_check: true});
redisClient.auth(rc.auth);

lab.test(file +" Confirm RedisCloud is accessible GET/SET", function(done) {

var rc = require('../lib/redis_config.js');
console.log(rc);
var redisClient = redis.createClient(rc.port, rc.host, {no_ready_check: true});
redisClient.auth(rc.auth);

redisClient.set('redis', 'working', redisClient.print);
console.log("✓ Redis Client connected to: " + redisClient.address);
assert(redisClient.address !== '127.0.0.1:6379', "✓ Redis Client connected to: " + redisClient.address)
Expand Down

0 comments on commit 8b4a1df

Please sign in to comment.