UNPKG

2.66 kBJavaScriptView Raw
1// Jasmine test related to the vmauthor virtual machine. The vmauthor
2// virtual machine hosts a full constellation of CodeGradX servers.
3// The vmauthor virtual machine is available from
4// http://paracamplus.com/CodeGradX/VM/latest/
5
6var CodeGradX = require('codegradxlib');
7var Agent = require('../codegradxagent.js');
8var vmauthor = require('./vmauthor-data.js');
9var vmauthData = require('./vmauth-data.json');
10
11describe("CodeGradXagent process Job", function () {
12
13 function initializer (agent) {
14 // User VMauthor's servers:
15 agent.state = new CodeGradX.State(vmauthor.initialize);
16 return agent;
17 }
18
19 it("should be loaded", function () {
20 expect(Agent).toBeDefined();
21 var agent = new CodeGradX.Agent(initializer);
22 expect(agent).toBeDefined();
23 });
24
25 function make_faildone (done) {
26 return function faildone (reason) {
27 //agent.state.debug(reason).show();
28 //console.log(reason);
29 fail(reason);
30 done();
31 };
32 }
33
34 // Get the safecookie identifying exercise com.paracamplus.li205.function.1
35 var exercise1;
36
37 it("should get hold of exercise", function (done) {
38 agent = new CodeGradX.Agent(initializer);
39 var faildone = make_faildone(done);
40 var exerciseName = "org.example.li205.function.1";
41 agent.process([
42 "--user", vmauthData.login,
43 "--password", vmauthData.password
44 ]).then(function (user) {
45 expect(user).toBeDefined();
46 user.getCampaign('example').then(function (campaign) {
47 expect(campaign).toBeDefined();
48 expect(campaign.name).toBe('example');
49 campaign.getExercise(exerciseName).then(function (exercise) {
50 expect(exercise).toBeDefined();
51 exercise1 = exercise;
52 //console.log(exercise);
53 done();
54 }, faildone);
55 }, faildone);
56 }, faildone);
57 }, 10*1000); // 10 seconds
58
59 it("send a job", function (done) {
60 agent = new CodeGradX.Agent(initializer);
61 expect(CodeGradX.getCurrentAgent()).toBe(agent);
62 var faildone = make_faildone(done);
63 agent.process([
64 "-v",
65 "--user", vmauthData.login,
66 "--password", vmauthData.password,
67 "--type", 'job',
68 "--stuff", 'spec/min.c',
69 "--exercise", exercise1.safecookie
70 ]).then(function (job) {
71 expect(job).toBeDefined();
72 done();
73 }, faildone);
74 }, 100*1000); // 100 seconds
75
76});