Example #1
0
const prepare = async () => {

  // make test dir
  await rimrafAsync('tmptest')
  await mkdirpAsync('tmptest')

  // set path root
  await paths.setRootAsync(path.join(cwd, 'tmptest'))

  // fake drive dir
  let dir = paths.get('drives')
  await mkdirpAsync(path.join(dir, drv001UUID))
  await mkdirpAsync(path.join(dir, drv002UUID))
  
  // write model files
  dir = paths.get('models')
  let tmpdir = paths.get('tmp')
  await fs.writeFileAsync(path.join(dir, 'users.json'), JSON.stringify(users, null, '  '))
  await fs.writeFileAsync(path.join(dir, 'drives.json'), JSON.stringify(drives, null, '  '))

  // create models
  let umod = await createUserModelAsync(path.join(dir, 'users.json'), tmpdir)
  let dmod = await createDriveModelAsync(path.join(dir, 'drives.json'), tmpdir)

  // set models
  models.setModel('user', umod)
  models.setModel('drive', dmod)
}
Example #2
0
  it('created mediatalk store should have rootdir, tmpdir, and docstore', function(done) {

    let tstore = createMediaTalkStore(docstore)
    expect(tstore.rootdir).to.equal(paths.get('mediatalk'))
    expect(tstore.tmpdir).to.equal(paths.get('tmp'))
    expect(tstore.docstore).to.equal(docstore)
    done()
  })
Example #3
0
    tstore.store(talkdoc001, err => {
      if (err) return done(err)
      let tsroot = paths.get('mediatalk')
      let refpath = path.join(tsroot, user001 + '.' + digest001)

      fs.readFile(refpath, (err, data) => {
        if (err) return done(err) 
        expect(data.toString()).to.equal(talkdoc001Hash)
        done()
      })
    })
Example #4
0
      return (async () => {

        await fakePathModel(path.join(cwd, 'tmptest'), users, drives)

        // fake dir and file in drive
        let dir = paths.get('drives')
        await mkdirpAsync(path.join(dir, drv001UUID, 'world'))
        await fs.writeFileAsync(path.join(dir, drv001UUID, 'file001.png'), '0123456789ABCDEFGHIJKLMN')
        let stat = await fs.statAsync(path.join(dir, drv001UUID, 'file001.png'))
        file001Timestamp = stat.mtime.getTime()
        let file001attr = `{"uuid":"${file001UUID}","owner":[],"hash":"141f8b5fb558f3f84949abcba9ca15326b1b6cf335aa845f5ea6f3d21e3061a8","magic":"ASCII text, with no line terminators","htime":${file001Timestamp.toString()}}`
        await Promise.promisify(xattr.set)(path.join(dir, drv001UUID, 'file001.png'), 'user.fruitmix', file001attr)
        
        repo = await fakeRepoSilenced()
        token = await requestTokenAsync(app, userUUID, 'world')
      })()