Skip to content

Commit

Permalink
Merge pull request #9 from Madadata/Add/driver-api
Browse files Browse the repository at this point in the history
Add/driver api
  • Loading branch information
Chyroc-MD authored Jan 11, 2017
2 parents efdf01c + 8201344 commit a293f00
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
18 changes: 14 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@ import url from 'url'
import path from 'path'
import querystring from 'querystring'

const versionUri = 'version'
const driverUri = 'v1/driver'

export class Hasoop {
constructor (config) {
this.userName = config.userName
this.host = config.host
this.port = config.port
this.weapp = config.webapp

this.versionUri = 'version'
}

formatUrl ([basicPath, queryObject = {}], ...otherPath) {
queryObject['user.name'] = this.userName
const urlQuery = querystring.stringify(queryObject)
const urlPath = path.join(this.weapp, basicPath, otherPath.length === 0 ? '' : path.join(otherPath))
const urlPath = path.join(
this.weapp,
basicPath,
...otherPath
)
const urlObj = {
protocol: 'http:',
slashes: true,
Expand All @@ -34,7 +39,12 @@ export class Hasoop {
}

getVersion () {
const url = this.formatUrl([this.versionUri])
const url = this.formatUrl([versionUri])
return sendGetRequest(url)
}

getDriver () {
const url = this.formatUrl([driverUri], 'all')
return sendGetRequest(url)
}
}
3 changes: 3 additions & 0 deletions src/setGetOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**
* Created by Chyroc on 17/1/11.
*/
11 changes: 5 additions & 6 deletions test/driver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
*/

import { expect } from 'chai'
import { Hasoop } from '../src/index'

const sqoopClient = new Hasoop('')
import { sqoopClient } from './index'

suite('driver', () => {
test.skip('getDriver', () => {
sqoopClient.getDriver()
test('getDriver', async () => {
const data = await sqoopClient.getDriver()
expect(data['version']).to.equal('1')
expect(data['all-config-resources']['jarConfig.label']).to.equal('Classpath configuration')
})

})

0 comments on commit a293f00

Please sign in to comment.