Blob Blame History Raw
From ee7985495d92a9bafa84cea60104469bd35b73fe Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Wed, 17 Jul 2019 20:44:28 -0700
Subject: [PATCH] t/api/03-auth.t: don't actually wipe asset files from disk

In testing whether we're allowed to or forbidden from deleting
assets in various cases, we actually wind up deleting an asset.
This is a problem if t/ui/07-file.t runs after this test,
because one of its subtests relies on that asset being present.
This doesn't show up in Travis runs because the UI and API tests
are run in separate jobs, but it *does* show up in package
builds - you can see the test failing in OBS openQA package
build logs, for instance.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
 t/api/03-auth.t | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/t/api/03-auth.t b/t/api/03-auth.t
index 8cbe1e23..5a486672 100644
--- a/t/api/03-auth.t
+++ b/t/api/03-auth.t
@@ -24,6 +24,7 @@ BEGIN {
 
 use FindBin;
 use lib "$FindBin::Bin/../lib";
+use Test::MockModule;
 use Test::More;
 use Test::Mojo;
 use Test::Warnings ':all';
@@ -42,6 +43,11 @@ my $app = $t->app;
 $t->ua(OpenQA::Client->new()->ioloop(Mojo::IOLoop->singleton));
 $t->app($app);
 
+# we don't want to *actually* delete any assets when we're testing
+# whether we're allowed to or not, so let's mock that out
+my $mock_asset = Test::MockModule->new('OpenQA::Schema::Result::Assets');
+$mock_asset->mock(remove_from_disk => sub { return 1; });
+
 subtest 'authentication routes for plugins' => sub {
     my $ensure_admin = $t->app->routes->find('api_ensure_admin');
     ok $ensure_admin, 'api_ensure_admin route found';
-- 
2.22.0