-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
544 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
defmodule SWAPI.FilmsTest do | ||
use SWAPI.DataCase | ||
|
||
alias SWAPI.Films | ||
|
||
describe "films" do | ||
alias SWAPI.Schemas.Film | ||
|
||
import SWAPI.FilmsFixtures | ||
|
||
@invalid_attrs %{title: nil, episode_id: nil, opening_crawl: nil, director: nil, producer: nil, release_date: nil} | ||
|
||
test "list_films/0 returns all films" do | ||
film = film_fixture() | ||
assert Films.list_films() == [film] | ||
end | ||
|
||
test "get_film!/1 returns the film with given id" do | ||
film = film_fixture() | ||
assert Films.get_film!(film.id) == film | ||
end | ||
|
||
test "create_film/1 with valid data creates a film" do | ||
valid_attrs = %{title: "some title", episode_id: 42, opening_crawl: "some opening_crawl", director: "some director", producer: "some producer", release_date: ~D[2023-11-28]} | ||
|
||
assert {:ok, %Film{} = film} = Films.create_film(valid_attrs) | ||
assert film.title == "some title" | ||
assert film.episode_id == 42 | ||
assert film.opening_crawl == "some opening_crawl" | ||
assert film.director == "some director" | ||
assert film.producer == "some producer" | ||
assert film.release_date == ~D[2023-11-28] | ||
end | ||
|
||
test "create_film/1 with invalid data returns error changeset" do | ||
assert {:error, %Ecto.Changeset{}} = Films.create_film(@invalid_attrs) | ||
end | ||
|
||
test "update_film/2 with valid data updates the film" do | ||
film = film_fixture() | ||
update_attrs = %{title: "some updated title", episode_id: 43, opening_crawl: "some updated opening_crawl", director: "some updated director", producer: "some updated producer", release_date: ~D[2023-11-29]} | ||
|
||
assert {:ok, %Film{} = film} = Films.update_film(film, update_attrs) | ||
assert film.title == "some updated title" | ||
assert film.episode_id == 43 | ||
assert film.opening_crawl == "some updated opening_crawl" | ||
assert film.director == "some updated director" | ||
assert film.producer == "some updated producer" | ||
assert film.release_date == ~D[2023-11-29] | ||
end | ||
|
||
test "update_film/2 with invalid data returns error changeset" do | ||
film = film_fixture() | ||
assert {:error, %Ecto.Changeset{}} = Films.update_film(film, @invalid_attrs) | ||
assert film == Films.get_film!(film.id) | ||
end | ||
|
||
test "delete_film/1 deletes the film" do | ||
film = film_fixture() | ||
assert {:ok, %Film{}} = Films.delete_film(film) | ||
assert_raise Ecto.NoResultsError, fn -> Films.get_film!(film.id) end | ||
end | ||
|
||
test "change_film/1 returns a film changeset" do | ||
film = film_fixture() | ||
assert %Ecto.Changeset{} = Films.change_film(film) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
defmodule SWAPI.PeopleTest do | ||
use SWAPI.DataCase | ||
|
||
alias SWAPI.People | ||
|
||
describe "people" do | ||
alias SWAPI.Schemas.Person | ||
|
||
import SWAPI.PeopleFixtures | ||
|
||
@invalid_attrs %{name: nil, birth_year: nil, eye_color: nil, gender: nil, hair_color: nil, height: nil, mass: nil, skin_color: nil} | ||
|
||
test "list_people/0 returns all people" do | ||
person = person_fixture() | ||
assert People.list_people() == [person] | ||
end | ||
|
||
test "get_person!/1 returns the person with given id" do | ||
person = person_fixture() | ||
assert People.get_person!(person.id) == person | ||
end | ||
|
||
test "create_person/1 with valid data creates a person" do | ||
valid_attrs = %{name: "some name", birth_year: "some birth_year", eye_color: "some eye_color", gender: "some gender", hair_color: "some hair_color", height: "some height", mass: "some mass",skin_color: "some skin_color"} | ||
|
||
assert {:ok, %Person{} = person} = People.create_person(valid_attrs) | ||
assert person.name == "some name" | ||
assert person.birth_year == "some birth_year" | ||
assert person.eye_color == "some eye_color" | ||
assert person.gender == "some gender" | ||
assert person.hair_color == "some hair_color" | ||
assert person.height == "some height" | ||
assert person.mass == "some mass" | ||
assert person.skin_color == "some skin_color" | ||
end | ||
|
||
test "create_person/1 with invalid data returns error changeset" do | ||
assert {:error, %Ecto.Changeset{}} = People.create_person(@invalid_attrs) | ||
end | ||
|
||
test "update_person/2 with valid data updates the person" do | ||
person = person_fixture() | ||
update_attrs = %{name: "some updated name", birth_year: "some updated birth_year", eye_color: "some updated eye_color", gender: "some updated gender", hair_color: "some updated hair_color", height: "some updated height", mass: "some updated mass", skin_color: "some updated skin_color"} | ||
|
||
assert {:ok, %Person{} = person} = People.update_person(person, update_attrs) | ||
assert person.name == "some updated name" | ||
assert person.birth_year == "some updated birth_year" | ||
assert person.eye_color == "some updated eye_color" | ||
assert person.gender == "some updated gender" | ||
assert person.hair_color == "some updated hair_color" | ||
assert person.height == "some updated height" | ||
assert person.mass == "some updated mass" | ||
assert person.skin_color == "some updated skin_color" | ||
end | ||
|
||
test "update_person/2 with invalid data returns error changeset" do | ||
person = person_fixture() | ||
assert {:error, %Ecto.Changeset{}} = People.update_person(person, @invalid_attrs) | ||
assert person == People.get_person!(person.id) | ||
end | ||
|
||
test "delete_person/1 deletes the person" do | ||
person = person_fixture() | ||
assert {:ok, %Person{}} = People.delete_person(person) | ||
assert_raise Ecto.NoResultsError, fn -> People.get_person!(person.id) end | ||
end | ||
|
||
test "change_person/1 returns a person changeset" do | ||
person = person_fixture() | ||
assert %Ecto.Changeset{} = People.change_person(person) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
defmodule SWAPI.PlanetsTest do | ||
use SWAPI.DataCase | ||
|
||
alias SWAPI.Planets | ||
|
||
describe "planets" do | ||
alias SWAPI.Schemas.Planet | ||
|
||
import SWAPI.PlanetsFixtures | ||
|
||
@invalid_attrs %{name: nil, diameter: nil, rotation_period: nil, orbital_period: nil, gravity: nil, population: nil, climate: nil, terrain: nil, surface_water: nil} | ||
|
||
test "list_planets/0 returns all planets" do | ||
planet = planet_fixture() | ||
assert Planets.list_planets() == [planet] | ||
end | ||
|
||
test "get_planet!/1 returns the planet with given id" do | ||
planet = planet_fixture() | ||
assert Planets.get_planet!(planet.id) == planet | ||
end | ||
|
||
test "create_planet/1 with valid data creates a planet" do | ||
valid_attrs = %{name: "some name", diameter: "some diameter", rotation_period: "some rotation_period", orbital_period: "some orbital_period", gravity: "some gravity", population: "some population", climate: "some climate", terrain: "some terrain", surface_water: "some surface_water"} | ||
|
||
assert {:ok, %Planet{} = planet} = Planets.create_planet(valid_attrs) | ||
assert planet.name == "some name" | ||
assert planet.diameter == "some diameter" | ||
assert planet.rotation_period == "some rotation_period" | ||
assert planet.orbital_period == "some orbital_period" | ||
assert planet.gravity == "some gravity" | ||
assert planet.population == "some population" | ||
assert planet.climate == "some climate" | ||
assert planet.terrain == "some terrain" | ||
assert planet.surface_water == "some surface_water" | ||
end | ||
|
||
test "create_planet/1 with invalid data returns error changeset" do | ||
assert {:error, %Ecto.Changeset{}} = Planets.create_planet(@invalid_attrs) | ||
end | ||
|
||
test "update_planet/2 with valid data updates the planet" do | ||
planet = planet_fixture() | ||
update_attrs = %{name: "some updated name", diameter: "some updated diameter", rotation_period: "some updated rotation_period", orbital_period: "some updated orbital_period", gravity: "some updated gravity", population: "some updated population", climate: "some updated climate", terrain: "some updated terrain", surface_water: "some updated surface_water"} | ||
|
||
assert {:ok, %Planet{} = planet} = Planets.update_planet(planet, update_attrs) | ||
assert planet.name == "some updated name" | ||
assert planet.diameter == "some updated diameter" | ||
assert planet.rotation_period == "some updated rotation_period" | ||
assert planet.orbital_period == "some updated orbital_period" | ||
assert planet.gravity == "some updated gravity" | ||
assert planet.population == "some updated population" | ||
assert planet.climate == "some updated climate" | ||
assert planet.terrain == "some updated terrain" | ||
assert planet.surface_water == "some updated surface_water" | ||
end | ||
|
||
test "update_planet/2 with invalid data returns error changeset" do | ||
planet = planet_fixture() | ||
assert {:error, %Ecto.Changeset{}} = Planets.update_planet(planet, @invalid_attrs) | ||
assert planet == Planets.get_planet!(planet.id) | ||
end | ||
|
||
test "delete_planet/1 deletes the planet" do | ||
planet = planet_fixture() | ||
assert {:ok, %Planet{}} = Planets.delete_planet(planet) | ||
assert_raise Ecto.NoResultsError, fn -> Planets.get_planet!(planet.id) end | ||
end | ||
|
||
test "change_planet/1 returns a planet changeset" do | ||
planet = planet_fixture() | ||
assert %Ecto.Changeset{} = Planets.change_planet(planet) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
defmodule SWAPI.SpeciesTest do | ||
use SWAPI.DataCase | ||
|
||
alias SWAPI.Species | ||
|
||
describe "species" do | ||
alias SWAPI.Schemas.Species, as: SpeciesSchema | ||
|
||
import SWAPI.SpeciesFixtures | ||
|
||
@invalid_attrs %{name: nil, classification: nil, designation: nil, average_height: nil, average_lifespan: nil, eye_colors: nil, hair_colors: nil, skin_colors: nil, language: nil} | ||
|
||
test "list_species/0 returns all species" do | ||
species = species_fixture() | ||
assert Species.list_species() == [species] | ||
end | ||
|
||
test "get_species!/1 returns the species with given id" do | ||
species = species_fixture() | ||
assert Species.get_species!(species.id) == species | ||
end | ||
|
||
test "create_species/1 with valid data creates a species" do | ||
valid_attrs = %{name: "some name", classification: "some classification", designation: "some designation", average_height: "some average_height", average_lifespan: "some average_lifespan", eye_colors: "some eye_colors", hair_colors: "some hair_colors", skin_colors: "some skin_colors", language: "some language"} | ||
|
||
assert {:ok, %SpeciesSchema{} = species} = Species.create_species(valid_attrs) | ||
assert species.name == "some name" | ||
assert species.classification == "some classification" | ||
assert species.designation == "some designation" | ||
assert species.average_height == "some average_height" | ||
assert species.average_lifespan == "some average_lifespan" | ||
assert species.eye_colors == "some eye_colors" | ||
assert species.hair_colors == "some hair_colors" | ||
assert species.skin_colors == "some skin_colors" | ||
assert species.language == "some language" | ||
end | ||
|
||
test "create_species/1 with invalid data returns error changeset" do | ||
assert {:error, %Ecto.Changeset{}} = Species.create_species(@invalid_attrs) | ||
end | ||
|
||
test "update_species/2 with valid data updates the species" do | ||
species = species_fixture() | ||
update_attrs = %{name: "some updated name", classification: "some updated classification", designation: "some updated designation", average_height: "some updated average_height", average_lifespan: "some updated average_lifespan", eye_colors: "some updated eye_colors", hair_colors: "some updated hair_colors", skin_colors: "some updated skin_colors", language: "some updated language"} | ||
|
||
assert {:ok, %SpeciesSchema{} = species} = Species.update_species(species, update_attrs) | ||
assert species.name == "some updated name" | ||
assert species.classification == "some updated classification" | ||
assert species.designation == "some updated designation" | ||
assert species.average_height == "some updated average_height" | ||
assert species.average_lifespan == "some updated average_lifespan" | ||
assert species.eye_colors == "some updated eye_colors" | ||
assert species.hair_colors == "some updated hair_colors" | ||
assert species.skin_colors == "some updated skin_colors" | ||
assert species.language == "some updated language" | ||
end | ||
|
||
test "update_species/2 with invalid data returns error changeset" do | ||
species = species_fixture() | ||
assert {:error, %Ecto.Changeset{}} = Species.update_species(species, @invalid_attrs) | ||
assert species == Species.get_species!(species.id) | ||
end | ||
|
||
test "delete_species/1 deletes the species" do | ||
species = species_fixture() | ||
assert {:ok, %SpeciesSchema{}} = Species.delete_species(species) | ||
assert_raise Ecto.NoResultsError, fn -> Species.get_species!(species.id) end | ||
end | ||
|
||
test "change_species/1 returns a species changeset" do | ||
species = species_fixture() | ||
assert %Ecto.Changeset{} = Species.change_species(species) | ||
end | ||
end | ||
end |
Oops, something went wrong.