bitwalker / timex_ecto

An adapter for using Timex DateTimes with Ecto
MIT License
162 stars 68 forks source link

Put EctoTest.Repo so that mix ecto.create will work #73

Closed aforward closed 5 years ago

aforward commented 7 years ago

Failing tests urk me... so I hopped back on. I actually "fixed" this locally, but then undid it (as I didn't love the solution, but didn't realize it was necessary to make it work in "more" environments).

If the repo isn't available, then mix ecto.create gets confused.

18:40 timex_ecto (f/test_repo)$ MIX_ENV=test mix ecto.create
Compiling 1 file (.ex)
Generated timex_ecto app
** (Mix) Could not load EctoTest.Repo, error: :nofile. Please configure your app accordingly or pass a repo with the -r option.

I was not able to be -r to work.

With this change, we can run MIX_ENV=test mix ecto.create. The travis config should now work out of the box as the MIX_ENV is always test.

aforward commented 7 years ago

Not quite there...

22:43:57.329 [warn]  %Postgrex.Query{columns: nil, name: "", param_formats: nil, param_oids: nil, param_types: nil, ref: #Reference<0.0.2.550>, result_formats: nil, result_oids: nil, result_types: nil, statement: ["INSERT INTO ", [34, "users", 34], [], [32, 40, [[[[[[[[[], [34, "date_test", 34], 44], [34, "datetime_test", 34], 44], [34, "datetimetz_test", 34], 44], [34, "name", 34], 44], [34, "time_test", 34], 44], [34, "timestamptz_test", 34], 44], [34, "inserted_at", 34], 44], 34, "updated_at", 34], ") VALUES ", [], 40, [[[[[[[[[], [36 | "1"], 44], [36 | "2"], 44], [36 | "3"], 44], [36 | "4"], 44], [36 | "5"], 44], [36 | "6"], 44], [36 | "7"], 44], 36 | "8"], 41], [], " RETURNING ", [], 34, "id", 34], types: nil} uses unknown oid `24586` causing bootstrap
22:43:57.342 [debug] QUERY OK db=17.8ms
INSERT INTO "users" ("date_test","datetime_test","datetimetz_test","name","time_test","timestamptz_test","inserted_at","updated_at") VALUES ($1,$2,$3,$4,$5,$6,$7,$8) RETURNING "id" [{2017, 9, 26}, {{2017, 9, 26}, {22, 43, 57, 304451}}, {{{2017, 9, 27}, {0, 43, 57, 304451}}, "Europe/Copenhagen"}, "Paul", {12, 30, 15, 120}, {{2017, 9, 26}, {22, 43, 57, 312593}}, {{2017, 9, 26}, {22, 43, 57, 0}}, {{2017, 9, 26}, {22, 43, 57, 0}}]
22:43:57.343 [debug] QUERY OK source="users" db=0.6ms decode=0.3ms
SELECT u0."id", u0."name", u0."date_test", u0."time_test", u0."datetime_test", u0."datetimetz_test", u0."timestamptz_test", u0."inserted_at", u0."updated_at" FROM "users" AS u0 []
  1) test integrates successfully with Ecto (Timex.Ecto.Test)
     test/timex_ecto_test.exs:89
     ** (MatchError) no match of right hand side value: [%EctoTest.User{__meta__: #Ecto.Schema.Metadata<:loaded, "users">, date_test: ~D[2017-09-26], datetime_test: #<DateTime(2017-09-26T22:43:57.304451Z Etc/UTC)>, datetimetz_test: #<DateTime(2017-09-27T00:43:57.304451+02:00 Europe/Copenhagen)>, id: 1, inserted_at: #<DateTime(2017-09-26T22:43:57Z Etc/UTC)>, name: "Paul", time_test: #<Duration(PT12H30M15.00012S)>, timestamptz_test: #<DateTime(2017-09-26T22:43:57.312593+00:00 UTC)>, updated_at: #<DateTime(2017-09-26T22:43:57Z Etc/UTC)>}]
     stacktrace:
       test/timex_ecto_test.exs:111: (test)
aforward commented 7 years ago

Looks like a microsecond issue

     code:  assert same_user.timestamptz_test() == timestamptz
     left:  %DateTime{calendar: Calendar.ISO, day: 26, hour: 18, minute: 56, month: 9, second: 54, std_offset: 3600, time_zone: "America/Toronto", utc_offset: -18000, year: 2017, zone_abbr: "EDT", microsecond: {575070, 5}}
     right: %DateTime{calendar: Calendar.ISO, day: 26, hour: 18, minute: 56, month: 9, second: 54, std_offset: 3600, time_zone: "America/Toronto", utc_offset: -18000, year: 2017, zone_abbr: "EDT", microsecond: {575070, 6}}