/*
 * Licensed to Cloudkick, Inc ('Cloudkick') under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * Cloudkick licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var assert = require('assert');

var serviceManagement = require('service_management');

var manager = serviceManagement.getManager('runit').getManager();

exports['test_run_action_invalid_action'] = function() {
  manager.runAction('service1', 'invalidAction', function(err) {
    assert.ok(err);
    assert.match(err.message, /invalid action/i);
  });
};

@@ -873,24 +873,97 @@
 anagement');
+%0Avar runitTemplates = require('service_management/runit/templates/base');
 %0A%0Avar manage
@@ -1220,8 +1220,580 @@
  %7D);%0A%7D;%0A
+%0Aexports%5B'test_runit_buildRunFile'%5D = function() %7B%0A  var result1 = runitTemplates.buildRunFile('/usr/bin/node server.js', '/opt/test', true);%0A  var result2 = runitTemplates.buildRunFile('/usr/bin/node server.js', '/opt/test', false);%0A  var result3 = runitTemplates.buildRunFile('/usr/bin/node server.js', null, false);%0A%0A  assert.equal(result1, '#!/bin/bash%5Cncd %22/opt/test%22 ; exec /usr/bin/node server.js 2%3E&1');%0A  assert.equal(result2, '#!/bin/bash%5Cncd %22/opt/test%22 ; exec /usr/bin/node server.js');%0A  assert.equal(result3, '#!/bin/bash%5Cnexec /usr/bin/node server.js');%0A%7D;%0A

Add a test for runit template rendering.