<commit_before>var HexaDB = require( '..' )
var assert = require( 'assert' )

var db = new HexaDB( require( 'memdb' )() )

var triples = [{
  s: 'jonas',
  p: 'friend',
  o: 'computer',
},{
  s: 'computer',
  p: 'friend',
  o: 'jonas'
}]

suite( 'Update', function() {
  
  setup( function() {
    triples.forEach( function( triple ) {
      db.put( triple, Function.prototype )
    })
  })
  
  test( 'db#update', function( next ) {
    
    var replacement = {
      s: 'jonas',
      p: 'owner',
      o: 'computer'
    }
    
    db.update( triples[0], replacement, function( error ) {
      if( error ) return next( error )
      db.get({ s: 'jonas', p: 'owner' }, function( error, result ) {
        if( error ) return next( error )
        assert.equal( result[0].predicate, 'owner' )
        next()
      })
    })
    
  })
  
  test( 'db#updateStream' )
  
})<commit_msg>Updated test/update: Expanded triple for assertion<commit_after>var HexaDB = require( '..' )
var assert = require( 'assert' )

suite( 'Update', function() {
  
  var db = new HexaDB( require( 'memdb' )() )
  
  var triples = [{
    subject: 'jonas',
    predicate: 'friend',
    object: 'computer',
  },{
    subject: 'computer',
    predicate: 'friend',
    object: 'jonas',
  }]
  
  setup( function() {
    triples.forEach( function( triple ) {
      db.put( triple, Function.prototype )
    })
  })
  
  test( 'db#update', function( next ) {
    
    var replacement = {
      subject: 'jonas',
      predicate: 'owner',
      object: 'computer',
    }
    
    db.update( triples[0], replacement, function( error ) {
      if( error ) return next( error )
      db.get({ s: 'jonas', p: 'owner' }, function( error, result ) {
        if( error ) return next( error )
        assert.deepEqual( result[0], replacement )
        next()
      })
    })
    
  })
  
  test( 'db#updateStream' )
  
})
{'fraction_non_alphanumeric': 0.1696808510638298, 'fraction_numerical': 0.002127659574468085, 'mean_word_length': 2.323321554770318, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3896739', 'n_tokens_mistral': 658, 'n_tokens_neox': 648, 'n_words': 163}