aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Magorsch <max@magorsch.de>2019-10-16 18:48:30 +0200
committerMax Magorsch <max@magorsch.de>2019-10-16 18:53:19 +0200
commitf481a263234db28ff9b4e3010735d59e76b6d592 (patch)
tree77046894d044b5fb2c49c2aefa5ccc13a497bfa0 /test
parentAdd a docker-compose file for integration tests (diff)
downloadpackages-5-f481a263234db28ff9b4e3010735d59e76b6d592.tar.gz
packages-5-f481a263234db28ff9b4e3010735d59e76b6d592.tar.bz2
packages-5-f481a263234db28ff9b4e3010735d59e76b6d592.zip
Add a couple of initial integration tests
Add a couple of simple integration tests for each defined route to check whether a page containing the correct heading is returned. Signed-off-by: Max Magorsch <max@magorsch.de>
Diffstat (limited to 'test')
-rw-r--r--test/integration/about_routes_test.rb30
-rw-r--r--test/integration/arches_routes_test.rb25
-rw-r--r--test/integration/categories_routes_test.rb10
-rw-r--r--test/integration/feeds_test.rb29
-rw-r--r--test/integration/main_routes_test.rb15
-rw-r--r--test/integration/packages_routes_test.rb51
-rw-r--r--test/integration/useflag_routes_test.rb25
-rw-r--r--test/test_helper.rb4
8 files changed, 189 insertions, 0 deletions
diff --git a/test/integration/about_routes_test.rb b/test/integration/about_routes_test.rb
new file mode 100644
index 0000000..56c36a3
--- /dev/null
+++ b/test/integration/about_routes_test.rb
@@ -0,0 +1,30 @@
+require 'test_helper'
+
+class AboutRoutesTest < ActionDispatch::IntegrationTest
+
+ test "can see the about page" do
+ get "/about"
+ assert_select "h1", "About packages.gentoo.org"
+ end
+
+ test "can see the feedback page" do
+ get "/about/feedback"
+ assert_select "h1", "Feedback"
+ end
+
+ test "can see the about feeds page" do
+ get "/about/feeds"
+ assert_select "h1", "Update Feeds"
+ end
+
+ test "can see the about help page" do
+ get "/about/help"
+ assert_select "h1", "Help"
+ end
+
+ test "can see the changelog page" do
+ get "/about/changelog"
+ assert_select "h1", "Changelog"
+ end
+
+end
diff --git a/test/integration/arches_routes_test.rb b/test/integration/arches_routes_test.rb
new file mode 100644
index 0000000..2e673e2
--- /dev/null
+++ b/test/integration/arches_routes_test.rb
@@ -0,0 +1,25 @@
+require 'test_helper'
+
+class ArchesRoutesTest < ActionDispatch::IntegrationTest
+ test "can see the arches page" do
+ get "/arches"
+ assert_select "h1", "Architectures"
+ end
+
+ test "view keyworded packages for arch" do
+ arches = %w(alpha amd64 arm arm64 hppa ia64 ppc ppc64 sparc x86)
+ arches.each { |arch|
+ get ("/arches/" + arch + "/keyworded")
+ assert_select "h1", ("Keyworded Packages (" + arch + ")")
+ }
+ end
+
+ test "view stable packages for arch" do
+ arches = %w(alpha amd64 arm arm64 hppa ia64 ppc ppc64 sparc x86)
+ arches.each { |arch|
+ get ("/arches/" + arch + "/stable")
+ assert_select "h1", ("Newly Stable Packages (" + arch + ")")
+ }
+ end
+
+end
diff --git a/test/integration/categories_routes_test.rb b/test/integration/categories_routes_test.rb
new file mode 100644
index 0000000..a9f46c2
--- /dev/null
+++ b/test/integration/categories_routes_test.rb
@@ -0,0 +1,10 @@
+require 'test_helper'
+
+class CategoriesRoutesTest < ActionDispatch::IntegrationTest
+
+ test "can see the categories page" do
+ get "/categories"
+ assert_select "h1", "Packages"
+ end
+
+end
diff --git a/test/integration/feeds_test.rb b/test/integration/feeds_test.rb
new file mode 100644
index 0000000..12a9c2f
--- /dev/null
+++ b/test/integration/feeds_test.rb
@@ -0,0 +1,29 @@
+require 'test_helper'
+
+class FeedsTest < ActionDispatch::IntegrationTest
+
+ test "can see the added packages feed" do
+ get '/packages/added.atom'
+ assert_response :success
+ assert_equal 'application/atom+xml; charset=utf-8', @response.content_type
+ end
+
+ test "can see the updates packages feed" do
+ get '/packages/updated.atom'
+ assert_response :success
+ assert_equal 'application/atom+xml; charset=utf-8', @response.content_type
+ end
+
+ test "can see the newly stable packages feed" do
+ get '/packages/stable.atom'
+ assert_response :success
+ assert_equal 'application/atom+xml; charset=utf-8', @response.content_type
+ end
+
+ test "can see the keyworded packages feed" do
+ get '/packages/keyworded.atom'
+ assert_response :success
+ assert_equal 'application/atom+xml; charset=utf-8', @response.content_type
+ end
+
+end
diff --git a/test/integration/main_routes_test.rb b/test/integration/main_routes_test.rb
new file mode 100644
index 0000000..71803aa
--- /dev/null
+++ b/test/integration/main_routes_test.rb
@@ -0,0 +1,15 @@
+require 'test_helper'
+
+class MainRoutesTest < ActionDispatch::IntegrationTest
+ test "view landing page" do
+ get "/"
+ assert_select "h2", "Welcome to the Home of 1 Gentoo Packages"
+ end
+
+ test "test route not present" do
+ assert_raises(ActionController::RoutingError) do
+ get '/larry'
+ end
+ end
+
+end
diff --git a/test/integration/packages_routes_test.rb b/test/integration/packages_routes_test.rb
new file mode 100644
index 0000000..465af4b
--- /dev/null
+++ b/test/integration/packages_routes_test.rb
@@ -0,0 +1,51 @@
+require 'test_helper'
+
+class PackagesRoutesTest < ActionDispatch::IntegrationTest
+
+ test "packages landing page" do
+ get "/packages"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_select "h1", "Packages"
+ end
+
+ test "view existing package" do
+ get "/packages/virtual/packages"
+ assert_select ".kk-package-name", "packages"
+ end
+
+ test "search for non existing package" do
+ get "/packages/search?q=larry"
+ assert_select "h2", "Nothing found. :( Try again?"
+ end
+
+ test "search for existing package" do
+ get "/packages/search?q=packages"
+ assert_response :redirect
+ follow_redirect!
+ assert_response :success
+ assert_select ".kk-package-name", "packages"
+ end
+
+ test "added package page" do
+ get "/packages/added"
+ assert_select "h1", "Added Packages"
+ end
+
+ test "updated package page" do
+ get "/packages/updated"
+ assert_select "h1", "Updated Packages"
+ end
+
+ test "newly stable packages page" do
+ get "/packages/stable"
+ assert_select "h1", "Newly Stable Packages"
+ end
+
+ test "keyworded packages page" do
+ get "/packages/keyworded"
+ assert_select "h1", "Keyworded Packages"
+ end
+
+end \ No newline at end of file
diff --git a/test/integration/useflag_routes_test.rb b/test/integration/useflag_routes_test.rb
new file mode 100644
index 0000000..3ed5718
--- /dev/null
+++ b/test/integration/useflag_routes_test.rb
@@ -0,0 +1,25 @@
+require 'test_helper'
+
+class UseflagRoutesTest < ActionDispatch::IntegrationTest
+
+ test "can see the useflags page" do
+ get "/useflags"
+ assert_select "h1", "USE flags"
+ end
+
+ test "search for multiple existing useflag" do
+ get "/useflags/search?q=systemd"
+ assert_select "h1", "USE Flag Search Results for systemd"
+ end
+
+ test "search for non existing useflag" do
+ get "/useflags/search?q=larry"
+ assert_select "h1", "USE Flag Search Results for larry"
+ end
+
+ test "view existing useflag" do
+ get "/useflags/systemd"
+ assert_select "h1", "systemd"
+ end
+
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index c71aa37..db135c7 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -6,6 +6,10 @@ class ActiveSupport::TestCase
# Import some test data into the test indices
category = Portage::Repository::Category.new('test/fixtures/repo/virtual')
Category.new.import!(category)
+
+ package = Portage::Repository::Package.new('test/fixtures/repo/virtual/packages')
+ Package.new.import!(package, { package_state: 'new' })
+
UseflagsUpdateJob.new.perform
# Add more helper methods to be used by all tests here...
end