DestyNova

DestyNova

Programming Phoenix LiveView: B10 typos (page 12-100)

Some typos and confusing bits I’ve noticed in the first 100 pages or so:

  • pp 12: “Now, start the web server” – the output snippet should include the mix phx.server command. It’s listed on the previous page in the output from mix phx.new pento but no harm including it here (as with mix ecto.create).
  • pp 13: “You may have noticed that Phoenix fetched the dependencies on this list when you ran mix deps.get.” – I don’t remember mix deps.get being mentioned before. That was presumably triggered implicitly by running the phx.new or phx.server task?
  • pp 51: we'll execute the log_in_user/3 function implement by
    • implemented by
  • pp 62: When a live view first mounts in it’s disconnected state – s/it's/its
  • pp 69: We get six failures. – I got 108 failures on first run of mix test, so maybe the generated set of tests is bigger now… or it’s the result of attempting one of the exercises.
  • pp 70: But even after adding :register_and_log_in_user I get 108 failures that look like this:
     test/pento_web/live/product_live_test.exs:19
     ** (Postgrex.Error) ERROR 23502 (not_null_violation) null value in column "username" of relation "users" violates not-null constraint

         table: users
         column: username

     Failing row contains (628, user-576460752303420725@example.com, $2b$04$MBV9BcBPEKPQZo1Go1tTSOypd4ecjocA5rw9BzqvocXmLGWf0y7Xm, null, 2024-02-29 23:57:26, 2024-02-29 23:57:26, null).
  • I believe this happened because the exercise on page 61 involves adding a username field. I added it as unique and non-null in the migration and validations, but the generator in accounts_fixtures.ex didn’t know about it. Maybe it adds fields based on the registration_changeset function, where I hadn’t added username to the cast call.
    • Also, I tried mix ecto.reset a few times but found it didn’t delete tables… turns out I needed MIX_ENV=test mix ecto.reset

Then:

  1) test register user creates account and logs the user in (PentoWeb.UserRegistrationLiveTest)
     test/pento_web/live/user_registration_live_test.exs:40
     ** (ArgumentError) could not find non-disabled input, select or textarea with name "user[username]" within:

To fix this, I added a username field to lib/pento_web/live/user_registration_live.ex. Another test failure required the addition of :username to the changeset.required test. I’m a bit wary of this sort of test coupling, where the test just duplicates and restates the implementation.

  • pp 74: The Ecto.Changeset.cast/4 function filters the user data we pass into params. – s/params/attrs
  • pp 80: Changeset are – s/set/sets

Where Next?

Popular Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
New
telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
New
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
taguniversalmachine
Hi, I am getting an error I cannot figure out on my test. I have what I think is the exact code from the book, other than I changed “us...
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
PragmaticBookshelf
Stop developing web apps with yesterday’s tools. Today, developers are increasingly adopting Clojure as a web-development platform. See f...
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
New
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New
AstonJ
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
New
PragmaticBookshelf
This book forgoes the abstract and instead provides concrete examples to help you better leverage the unique properties of Elixir, Erlang...
New

Sub Categories: