 path = require 'path'
 os = require 'os'
 fs = require 'fs'
+mkdirp = require 'mkdirp'
 fixtures = require 'cozy-fixtures'
 if process.env.USE_JS
     prefix = path.join __dirname, '../build/'

    killServer: ->
        @server.close()

    clearDB: (done) ->
         fixtures.resetDatabase callback: done
	


    createDriver: (filename) ->
        (done) ->

            mkdirp DRIVERS_DIR, (err) ->
                return done err if err

                # Copy file so the original doesn't get deleted during the creation:
                extName = path.basename(filename) 
                fs.createReadStream(filename).pipe(fs.createWriteStream(os.tmpdir() + "/" + extName))
                
                fileData =
                    path: os.tmpdir() + "/" + extName

                # baseDriver = new Driver(fileData)
                Driver.create fileData, (err, driver) =>
                    console.log("CREATED DRIVER")
                    @driver = driver
                    done err

    makeTestClient: (done) ->
        old = new Client "http://localhost:#{TESTPORT}/"
