Пример #1
0
    it('verify multiple files can be uploaded in the same request parameter', callback => {
      TestsUtil.createTestServer((app, server, port) => {
        app.post('/testUploadFiles', (request, response) => {
          assert.ok(_.isArray(request.files.testFiles));
          assert.strictEqual(request.files.testFiles.length, 2);
          assert.strictEqual(request.files.testFiles[0].name, 'banditos.txt');
          assert.strictEqual(request.files.testFiles[1].name, 'banditos.txt');

          response.sendStatus(200);
          server.close(callback);
        });

        const opts = { method: 'POST', url: 'http://localhost:' + port + '/testUploadFiles' };
        RestUtil.request(opts, { testFiles: [getFileStream, getFileStream] });
      });
    });
Пример #2
0
        it('verify multiple files can be uploaded in the same request parameter', function(callback) {
            TestsUtil.createTestServer(function(app, server, port) {

                app.post('/testUploadFiles', function(request, response) {
                    assert.ok(_.isArray(request.files.testFiles));
                    assert.strictEqual(request.files.testFiles.length, 2);
                    assert.equal(request.files.testFiles[0].name, 'banditos.txt');
                    assert.equal(request.files.testFiles[1].name, 'banditos.txt');

                    response.send(200);
                    server.close(callback);
                });

                var opts = {'method': 'POST', 'url': 'http://localhost:' + port + '/testUploadFiles'};
                RestUtil.request(opts, {'testFiles': [getFileStream, getFileStream]});
            });
        });
Пример #3
0
    before(function(callback) {

        // Fill up the global admin rest context
        globalAdminRestContext = TestsUtil.createGlobalAdminRestContext();
        // Fill up the cam admin rest context
        camAdminRestContext = TestsUtil.createTenantAdminRestContext(global.oaeTests.tenants.cam.host);
        // Fill up the gt admin rest context
        gtAdminRestContext = TestsUtil.createTenantAdminRestContext(global.oaeTests.tenants.gt.host);

        // Create a new express application to mock a Learning Record Store
        TestsUtil.createTestServer(function(app, server, port) {

            app.post('/', function(req, res) {
                onRequest(req);
                res.send(200);
            });
            
            // Set the endpoint for the LRS
            ConfigTestUtil.updateConfigAndWait(camAdminRestContext, null, {'oae-tincanapi/lrs/endpoint': 'http://localhost:' + port}, function(err) {
                assert.ok(!err);
                callback();
            });
        });
    });