Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add test case

  • Loading branch information...
commit 6a372a99419fa19f756592aef6a2e09c6e17a0fa 1 parent d80ad9b
Hsiaoming Yang authored
View
3  .travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+ - 0.8
View
8 lib/core/config.js
@@ -13,6 +13,9 @@ var config = require('../helpers/config')
var utils = require('../utils')
var spmrcPath = path.join(process.env['HOME'], '.spm', 'spmrc')
utils.safeWrite(spmrcPath)
+if (!fs.existsSync(spmrcPath)) {
+ updateConfig({})
+}
exports.description = 'configuration for spm'
@@ -29,7 +32,7 @@ exports.config = function(key, value) {
if (!value) {
var ret = renderConfig(data);
keys.forEach(function(section) {
- ret = ret[section]
+ ret = ret ? ret[section]: null
})
return ret
}
@@ -62,9 +65,6 @@ exports.remove = function(section) {
exports.show = function() {
- if (!fs.existsSync(spmrcPath)) {
- updateConfig({'user': {'username': 'spm'}})
- }
var data = config.parseSync(spmrcPath)
console.log()
for (var section in data) {
View
7 package.json
@@ -5,11 +5,18 @@
"dependencies": {
"commander": ">=1.1.1"
},
+ "devDependencies": {
+ "mocha": "*",
+ "should": "*"
+ },
"bin": {
"spm": "bin/spm",
"spm-build": "bin/spm-build",
"spm-config": "bin/spm-config",
"spm-install": "bin/spm-install",
"spm-plugin": "bin/spm-plugin"
+ },
+ "scripts": {
+ "test": "./node_modules/.bin/mocha --reporter spec"
}
}
View
12 test/config.js
@@ -0,0 +1,12 @@
+var should = require('should')
+require('../index').logging.setlevel('error')
+var config = require('../lib/core/config')
+
+describe('config', function() {
+ it('should get section.key', function() {
+ config.config('section.key', 'value')
+ config.config('section.key').should.equal('value')
+ config.remove('section')
+ should.not.exist(config.config('section.key'))
+ })
+})
Please sign in to comment.
Something went wrong with that request. Please try again.