From ae822f13ddbfb8dc2291de6a20e4673a007cc51e Mon Sep 17 00:00:00 2001 From: VibhorCodecianGupta Date: Thu, 12 Jul 2018 02:58:05 +0530 Subject: [PATCH] added go spec --- .travis.yml | 1 + config.js | 7 ++++++- test/run.go.spec.ts | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/run.go.spec.ts diff --git a/.travis.yml b/.travis.yml index 8626aa4..9ff2a93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ install: - npm install -D - docker pull codingblocks/judge-worker-c - docker pull codingblocks/judge-worker-cpp + - docker pull codingblocks/judge-worker-golang - docker pull codingblocks/judge-worker-java8 - docker pull codingblocks/judge-worker-py2 - docker pull codingblocks/judge-worker-py3 diff --git a/config.js b/config.js index 9e71ebf..3ca152f 100644 --- a/config.js +++ b/config.js @@ -48,6 +48,11 @@ exports = module.exports = { SOURCE_FILE: 'script.rb', CPU_SHARE: "0.8", MEM_LIMIT: '300m' + }, + 'golang': { + SOURCE_FILE: 'main.go', + CPU_SHARE: "0.8", + MEM_LIMIT: '300m' } } -} \ No newline at end of file +} diff --git a/test/run.go.spec.ts b/test/run.go.spec.ts new file mode 100644 index 0000000..f800f65 --- /dev/null +++ b/test/run.go.spec.ts @@ -0,0 +1,26 @@ +import {execRun} from '../src/tasks/run' +import {expect} from 'chai' + +describe('run - golang', () => { + it('.go file runs correctly', () => { + execRun({ + id: 28, + lang: 'golang', + source: (new Buffer(` + package main; + + import "fmt"; + + func main() { + var text string + fmt.Scanf("%s", &text) + fmt.Println("Hello " + text) + } + + `)).toString('base64'), + stdin: (new Buffer('World')).toString('base64') + }, (runResult) => { + expect(new Buffer(runResult.stdout, 'base64').toString('ascii')).to.eq('Hello World') + }) + }) +})