{"size": 1959, "ext": "js", "max_stars_repo_path": "test/functional/gh29.js", "max_stars_repo_name": "cirruspath/verdaccio", "max_stars_repo_stars_event_min_datetime": "2018-05-04T07:11:02.000Z", "max_stars_repo_stars_event_max_datetime": "2018-05-04T07:11:02.000Z", "max_issues_repo_path": "test/functional/gh29.js", "max_issues_repo_name": "ngash/verdaccio", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/functional/gh29.js", "max_forks_repo_name": "ngash/verdaccio", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.0952380952, "max_line_length": 104, "alphanum_fraction": 0.5344563553}
import assert from 'assert';
import crypto from 'crypto';

function readfile(x) {
  return require('fs').readFileSync(__dirname + '/' + x);
}

export default function (server, server2) {

  test('downloading non-existent tarball #1 / srv2', () => {
    return server2.getTarball('testpkg-gh29', 'blahblah')
             .status(404)
             .body_error(/no such package/);
  });

  describe('pkg-gh29', () => {
    beforeAll(function() {
      return server.putPackage('testpkg-gh29', require('./fixtures/package')('testpkg-gh29'))
               .status(201)
               .body_ok(/created new package/);
    });

    test('creating new package / srv1', () => {});

    test('downloading non-existent tarball #2 / srv2', () => {
      return server2.getTarball('testpkg-gh29', 'blahblah')
               .status(404)
               .body_error(/no such file available/);
    });

    describe('tarball', () => {
      beforeAll(function() {
        return server.putTarball('testpkg-gh29', 'blahblah', readfile('fixtures/binary'))
                 .status(201)
                 .body_ok(/.*/);
      });

      test('uploading new tarball / srv1', () => {});

      describe('pkg version', () => {
        beforeAll(function() {
          const pkg = require('./fixtures/package')('testpkg-gh29');

          pkg.dist.shasum = crypto.createHash('sha1').update(readfile('fixtures/binary')).digest('hex');
          return server.putVersion('testpkg-gh29', '0.0.1', pkg)
                   .status(201)
                   .body_ok(/published/);
        });

        test('uploading new package version / srv1', () => {});

        test('downloading newly created tarball / srv2', () => {
          return server2.getTarball('testpkg-gh29', 'blahblah')
                 .status(200)
                 .then(function(body) {
                   assert.deepEqual(body, readfile('fixtures/binary'));
                 });
        });
      });
    });
  });
}
