7.4 KiB · text History 5dd4046
defmodule CartosnapApp.PhotosTest do
  use CartosnapApp.DataCase

  alias CartosnapApp.Photos

  describe "photo_trips" do
    alias CartosnapApp.Photos.Trip

    import CartosnapApp.PhotosFixtures

    @invalid_attrs %{date_end: nil, date_start: nil, geo: nil, meta: nil, name: nil}

    test "list_photo_trips/0 returns all photo_trips" do
      trip = trip_fixture()
      assert Photos.list_photo_trips() == [trip]
    end

    test "get_trip!/1 returns the trip with given id" do
      trip = trip_fixture()
      assert Photos.get_trip!(trip.id) == trip
    end

    test "create_trip/1 with valid data creates a trip" do
      valid_attrs = %{date_end: ~D[2022-03-28], date_start: ~D[2022-03-28], geo: "some geo", meta: %{}, name: "some name"}

      assert {:ok, %Trip{} = trip} = Photos.create_trip(valid_attrs)
      assert trip.date_end == ~D[2022-03-28]
      assert trip.date_start == ~D[2022-03-28]
      assert trip.geo == "some geo"
      assert trip.meta == %{}
      assert trip.name == "some name"
    end

    test "create_trip/1 with invalid data returns error changeset" do
      assert {:error, %Ecto.Changeset{}} = Photos.create_trip(@invalid_attrs)
    end

    test "update_trip/2 with valid data updates the trip" do
      trip = trip_fixture()
      update_attrs = %{date_end: ~D[2022-03-29], date_start: ~D[2022-03-29], geo: "some updated geo", meta: %{}, name: "some updated name"}

      assert {:ok, %Trip{} = trip} = Photos.update_trip(trip, update_attrs)
      assert trip.date_end == ~D[2022-03-29]
      assert trip.date_start == ~D[2022-03-29]
      assert trip.geo == "some updated geo"
      assert trip.meta == %{}
      assert trip.name == "some updated name"
    end

    test "update_trip/2 with invalid data returns error changeset" do
      trip = trip_fixture()
      assert {:error, %Ecto.Changeset{}} = Photos.update_trip(trip, @invalid_attrs)
      assert trip == Photos.get_trip!(trip.id)
    end

    test "delete_trip/1 deletes the trip" do
      trip = trip_fixture()
      assert {:ok, %Trip{}} = Photos.delete_trip(trip)
      assert_raise Ecto.NoResultsError, fn -> Photos.get_trip!(trip.id) end
    end

    test "change_trip/1 returns a trip changeset" do
      trip = trip_fixture()
      assert %Ecto.Changeset{} = Photos.change_trip(trip)
    end
  end

  describe "photo_photos" do
    alias CartosnapApp.Photos.Photo

    import CartosnapApp.PhotosFixtures

    @invalid_attrs %{blurhash: nil, date: nil, exif: nil, filename: nil, geo_point: nil, name: nil, promoted: nil, url_full: nil, url_original: nil, url_preview: nil, url_thumb: nil}

    test "list_photo_photos/0 returns all photo_photos" do
      photo = photo_fixture()
      assert Photos.list_photo_photos() == [photo]
    end

    test "get_photo!/1 returns the photo with given id" do
      photo = photo_fixture()
      assert Photos.get_photo!(photo.id) == photo
    end

    test "create_photo/1 with valid data creates a photo" do
      valid_attrs = %{blurhash: "some blurhash", date: ~D[2022-04-06], exif: %{}, filename: "some filename", geo_point: "some geo_point", name: "some name", promoted: true, url_full: "some url_full", url_original: "some url_original", url_preview: "some url_preview", url_thumb: "some url_thumb"}

      assert {:ok, %Photo{} = photo} = Photos.create_photo(valid_attrs)
      assert photo.blurhash == "some blurhash"
      assert photo.date == ~D[2022-04-06]
      assert photo.exif == %{}
      assert photo.filename == "some filename"
      assert photo.geo_point == "some geo_point"
      assert photo.name == "some name"
      assert photo.promoted == true
      assert photo.url_full == "some url_full"
      assert photo.url_original == "some url_original"
      assert photo.url_preview == "some url_preview"
      assert photo.url_thumb == "some url_thumb"
    end

    test "create_photo/1 with invalid data returns error changeset" do
      assert {:error, %Ecto.Changeset{}} = Photos.create_photo(@invalid_attrs)
    end

    test "update_photo/2 with valid data updates the photo" do
      photo = photo_fixture()
      update_attrs = %{blurhash: "some updated blurhash", date: ~D[2022-04-07], exif: %{}, filename: "some updated filename", geo_point: "some updated geo_point", name: "some updated name", promoted: false, url_full: "some updated url_full", url_original: "some updated url_original", url_preview: "some updated url_preview", url_thumb: "some updated url_thumb"}

      assert {:ok, %Photo{} = photo} = Photos.update_photo(photo, update_attrs)
      assert photo.blurhash == "some updated blurhash"
      assert photo.date == ~D[2022-04-07]
      assert photo.exif == %{}
      assert photo.filename == "some updated filename"
      assert photo.geo_point == "some updated geo_point"
      assert photo.name == "some updated name"
      assert photo.promoted == false
      assert photo.url_full == "some updated url_full"
      assert photo.url_original == "some updated url_original"
      assert photo.url_preview == "some updated url_preview"
      assert photo.url_thumb == "some updated url_thumb"
    end

    test "update_photo/2 with invalid data returns error changeset" do
      photo = photo_fixture()
      assert {:error, %Ecto.Changeset{}} = Photos.update_photo(photo, @invalid_attrs)
      assert photo == Photos.get_photo!(photo.id)
    end

    test "delete_photo/1 deletes the photo" do
      photo = photo_fixture()
      assert {:ok, %Photo{}} = Photos.delete_photo(photo)
      assert_raise Ecto.NoResultsError, fn -> Photos.get_photo!(photo.id) end
    end

    test "change_photo/1 returns a photo changeset" do
      photo = photo_fixture()
      assert %Ecto.Changeset{} = Photos.change_photo(photo)
    end
  end

  describe "photo_photo_trips" do
    alias CartosnapApp.Photos.PhotoTrip

    import CartosnapApp.PhotosFixtures

    @invalid_attrs %{}

    test "list_photo_photo_trips/0 returns all photo_photo_trips" do
      photo_trip = photo_trip_fixture()
      assert Photos.list_photo_photo_trips() == [photo_trip]
    end

    test "get_photo_trip!/1 returns the photo_trip with given id" do
      photo_trip = photo_trip_fixture()
      assert Photos.get_photo_trip!(photo_trip.id) == photo_trip
    end

    test "create_photo_trip/1 with valid data creates a photo_trip" do
      valid_attrs = %{}

      assert {:ok, %PhotoTrip{} = photo_trip} = Photos.create_photo_trip(valid_attrs)
    end

    test "create_photo_trip/1 with invalid data returns error changeset" do
      assert {:error, %Ecto.Changeset{}} = Photos.create_photo_trip(@invalid_attrs)
    end

    test "update_photo_trip/2 with valid data updates the photo_trip" do
      photo_trip = photo_trip_fixture()
      update_attrs = %{}

      assert {:ok, %PhotoTrip{} = photo_trip} = Photos.update_photo_trip(photo_trip, update_attrs)
    end

    test "update_photo_trip/2 with invalid data returns error changeset" do
      photo_trip = photo_trip_fixture()
      assert {:error, %Ecto.Changeset{}} = Photos.update_photo_trip(photo_trip, @invalid_attrs)
      assert photo_trip == Photos.get_photo_trip!(photo_trip.id)
    end

    test "delete_photo_trip/1 deletes the photo_trip" do
      photo_trip = photo_trip_fixture()
      assert {:ok, %PhotoTrip{}} = Photos.delete_photo_trip(photo_trip)
      assert_raise Ecto.NoResultsError, fn -> Photos.get_photo_trip!(photo_trip.id) end
    end

    test "change_photo_trip/1 returns a photo_trip changeset" do
      photo_trip = photo_trip_fixture()
      assert %Ecto.Changeset{} = Photos.change_photo_trip(photo_trip)
    end
  end
end