<commit_before>/*
* meta-test.js: Openstack updateImageMeta() function test .
*
* (C) 2012 Nodejitsu Inc.
*
*/

var fs = require('fs'),
    path = require('path'),
    qs = require('qs'),
    should = require('should'),
    utile = require('utile'),
    async = require('async'),
    helpers = require('../../helpers'),
    hock = require('hock'),
    async = require('async'),
    _ = require('underscore'),
    Image = require('../../../lib/pkgcloud/core/compute/image').Image,
    mock = !!process.env.MOCK;

providers=["openstack"];


providers.forEach(function (provider) {
  describe('pkgcloud/common/compute/server [' + provider + ']', function () {

    var client = helpers.createClient(provider, 'compute'),
      context = {},
      authServer, server;

    before(function (done) {

      if (!mock) {
        return done();
      }

      async.parallel([
        function (next) {
          hock.createHock({
            port: 12345,
            throwOnUnmatched: false
          }, function (err, hockClient) {
            server = hockClient;
            next();
          });
        },
        function (next) {
          hock.createHock(12346, function (err, hockClient) {
            authServer = hockClient;
            next();
          });
        }
      ], done)
    });

    it('the getImages() function should return a list of images', function(done) {

      if (mock) {
        setupImagesMock(client, provider, {
          authServer: authServer,
          server: server
        });
      }

      client.getImages(function (err, images) {
        should.not.exist(err);
        should.exist(images);

        context.images = images

	images.forEach(function(img) {
          img.should.be.instanceOf(Image);
        });


        authServer && authServer.done();
        server && server.done();

        done();
      });
    });


    it('the updateImageMeta() method should update the image metadate', function (done) {
      if (mock) {
        setupMetaMock(client, provider, {
          authServer: authServer,
          server: server
        });
      }

      client.updateImageMeta(context.images[0].id, {"os_type" : "windows"}, function (err, img) {
        should.not.exist(err);
        should.exist(img);

        context.currentServer = server;

        authServer && authServer.done();
        server && server.done();
        done();

      });
    });<commit_msg>Update meta-test.js<commit_after>/*
* meta-test.js: Openstack updateImageMeta() function test .
*
* (C) 2012 Nodejitsu Inc.
*
*/

var fs = require('fs'),
    path = require('path'),
    qs = require('qs'),
    should = require('should'),
    utile = require('utile'),
    async = require('async'),
    helpers = require('../../helpers'),
    hock = require('hock'),
    async = require('async'),
    _ = require('underscore'),
    Image = require('../../../lib/pkgcloud/core/compute/image').Image,
    mock = !!process.env.MOCK;

providers=["openstack"];


providers.forEach(function (provider) {
  describe('pkgcloud/common/compute/server [' + provider + ']', function () {

    var client = helpers.createClient(provider, 'compute'),
      context = {},
      authServer, server;

    before(function (done) {

      if (!mock) {
        return done();
      }

      async.parallel([
        function (next) {
          hock.createHock({
            port: 12345,
            throwOnUnmatched: false
          }, function (err, hockClient) {
            server = hockClient;
            next();
          });
        },
        function (next) {
          hock.createHock(12346, function (err, hockClient) {
            authServer = hockClient;
            next();
          });
        }
      ], done)
    });

    it('the getImages() function should return a list of images', function(done) {

      if (mock) {
        setupImagesMock(client, provider, {
          authServer: authServer,
          server: server
        });
      }

      client.getImages(function (err, images) {
        should.not.exist(err);
        should.exist(images);

        context.images = images

	images.forEach(function(img) {
          img.should.be.instanceOf(Image);
        });


        authServer && authServer.done();
        server && server.done();

        done();
      });
    });


    it('the updateImageMeta() method should update the image metadata', function (done) {
      if (mock) {
        setupMetaMock(client, provider, {
          authServer: authServer,
          server: server
        });
      }
	
      var testMetadata = {"os_type" : "windows"};
	
      client.updateImageMeta(context.images[0].id, testMetadata, function (err, reply) {
        should.not.exist(err);
        should.exist(reply);
        should.exist(reply.metadata.os_type);
        reply.metadata.os_type.should.equal('windows');

        context.currentServer = server;

        authServer && authServer.done();
        server && server.done();
        done();

      });
    });
{'fraction_non_alphanumeric': 0.15154556403050984, 'fraction_numerical': 0.00602167804094741, 'mean_word_length': 2.0495716034271725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4870608', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1404, 'n_words': 290}