<commit_before>'use strict';

var chai = require('chai')
  , sinon = require('sinon')
  , Sequelize = require('../../index')
  , Promise = Sequelize.Promise
  , expect = chai.expect
  , Support = require(__dirname + '/../support')
  , DataTypes = require(__dirname + '/../../lib/data-types')
  , dialect = Support.getTestDialect()
  , datetime = require('chai-datetime')
  , _ = require('lodash')
  , assert = require('assert')
  , current = Support.sequelize;

chai.use(datetime);
chai.config.includeStack = true;

describe(Support.getTestDialectTeaser('Model'), function() {
  beforeEach(function() {
    this.clock = sinon.useFakeTimers();

    this.User = this.sequelize.define('user', {
      username: DataTypes.STRING,
      foo: {
        unique: 'foobar',
        type: DataTypes.STRING
      },
      bar: {
        unique: 'foobar',
        type: DataTypes.INTEGER
      }
    });

    return this.sequelize.sync({ force: true });
  });

  afterEach(function() {
    this.clock.restore();
  });

  if (current.dialect.supports.upserts) {
    describe.only('upsert', function() {
      it('works with upsert on id', function() {
        return this.User.upsert({ id: 42, username: 'john' }).bind(this).then(function(created) {
          if (dialect === 'sqlite') {
            expect(created).not.to.be.defined;
          } else {
            expect(created).to.be.ok;
          }

          this.clock.tick(2000); // Make sure to pass some time so updatedAt != createdAt
          return this.User.upsert({ id: 42, username: 'doe' });
        }).then(function(created) {
          if (dialect === 'sqlite') {
            expect(created).not.to.be.defined;<commit_msg>Remove .only courtesy of @janmeier <3<commit_after>'use strict';

var chai = require('chai')
  , sinon = require('sinon')
  , Sequelize = require('../../index')
  , Promise = Sequelize.Promise
  , expect = chai.expect
  , Support = require(__dirname + '/../support')
  , DataTypes = require(__dirname + '/../../lib/data-types')
  , dialect = Support.getTestDialect()
  , datetime = require('chai-datetime')
  , _ = require('lodash')
  , assert = require('assert')
  , current = Support.sequelize;

chai.use(datetime);
chai.config.includeStack = true;

describe(Support.getTestDialectTeaser('Model'), function() {
  beforeEach(function() {
    this.clock = sinon.useFakeTimers();

    this.User = this.sequelize.define('user', {
      username: DataTypes.STRING,
      foo: {
        unique: 'foobar',
        type: DataTypes.STRING
      },
      bar: {
        unique: 'foobar',
        type: DataTypes.INTEGER
      }
    });

    return this.sequelize.sync({ force: true });
  });

  afterEach(function() {
    this.clock.restore();
  });

  if (current.dialect.supports.upserts) {
    describe('upsert', function() {
      it('works with upsert on id', function() {
        return this.User.upsert({ id: 42, username: 'john' }).bind(this).then(function(created) {
          if (dialect === 'sqlite') {
            expect(created).not.to.be.defined;
          } else {
            expect(created).to.be.ok;
          }

          this.clock.tick(2000); // Make sure to pass some time so updatedAt != createdAt
          return this.User.upsert({ id: 42, username: 'doe' });
        }).then(function(created) {
          if (dialect === 'sqlite') {
            expect(created).not.to.be.defined;
{'fraction_non_alphanumeric': 0.16770370370370372, 'fraction_numerical': 0.005037037037037037, 'mean_word_length': 2.606837606837607, 'pattern_counts': {'":': 0, '<': 4, '<?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': '1972820', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1059, 'n_words': 204}