无法进行轨道测试甚至运行,UNIQUE约束失败:reviews.id:

时间:2018-03-26 22:18:15

标签: ruby-on-rails unit-testing testing sqlite

我开始考虑测试我正在研究的Rails应用程序,并且似乎无法生成默认生成的测试。我认为它与导轨产生固定装置的唯一ID有关。

我正在运行的测试就是: rails test test / controllers / pages_controller_test

完整的错误讯息: 错误: PagesControllerTest#test_should_get_home: ActiveRecord :: RecordNotUnique:SQLite3 :: ConstraintException:UNIQUE约束失败:reviews.id:INSERT INTO"评论" (" created_at"," updated_at"," id")VALUES(' 2018-03-26 21:55:24.345073',& #39; 2018-03-26 21:55:24.345073',980190962)

测试/控制器/ pages_controller_test

require 'test_helper'

class PagesControllerTest < ActionDispatch::IntegrationTest
  test "should get home" do
    get pages_home_url
    assert_response :success
  end

end

这就是reviews.yml的样子:

# Read about fixtures at 
http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
  comment: MyText
  star: 1
  reservation_id: one
  tourist_id: one
  guide_id: one
  type:

two:
  comment: MyText
  star: 1
  reservation_id: two
  tourist_id: two
  guide_id: two
  type:

0 个答案:

没有答案