Commit 513903e

mo khan <mo.khan@gmail.com>
2020-11-15 01:59:39
feat: find movies not by pixar
1 parent a5fba92
Changed files (2)
domain/movie_library.go
@@ -41,6 +41,12 @@ func (self *MovieLibrary) FindAllMoviesByPixarOrDisney() []Movie {
 	})
 }
 
+func (self *MovieLibrary) FindAllMoviesNotByPixar() []Movie {
+	return self.FindAll(func(x Movie) bool {
+		return x.Studio.Name != "Pixar"
+	})
+}
+
 func (self *MovieLibrary) Add(movie Movie) {
 	found := self.Find(func(x Movie) bool {
 		return x.Equals(movie)
test/unit/movie_library_test.go
@@ -74,5 +74,19 @@ func TestMovieLibrary(t *testing.T) {
 
 			assert.ElementsMatch(t, expected, movies)
 		})
+
+		t.Run("returns all movies not published by Pixar", func(t *testing.T) {
+			movies := subject.FindAllMoviesNotByPixar()
+			expected := [...]domain.Movie{
+				chasing_amy,
+				dumbo,
+				fantasia,
+				man_on_fire,
+				pinocchio,
+				shawshank_redemption,
+			}
+
+			assert.ElementsMatch(t, expected, movies)
+		})
 	})
 }