You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2017/03/20 01:09:17 UTC
[3/8] incubator-trafficcontrol git commit: add the 'tenant' fixture
add the 'tenant' fixture
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/d936a344
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/d936a344
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/d936a344
Branch: refs/heads/master
Commit: d936a3445643f4133164fcc487131c38b5ae43e2
Parents: 5e959d7
Author: nir-sopher <ni...@gmail.com>
Authored: Wed Mar 15 15:47:28 2017 +0200
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Sun Mar 19 19:08:28 2017 -0600
----------------------------------------------------------------------
traffic_ops/app/lib/Fixtures/Tenant.pm | 46 ++++++++++++++++++++
traffic_ops/app/lib/Test/TestHelper.pm | 3 ++
traffic_ops/app/t/api/1.2/cachegroup.t | 1 +
traffic_ops/app/t/api/1.2/federation_external.t | 1 +
traffic_ops/app/t/api/1.2/parameter.t | 1 +
traffic_ops/app/t/api/1.2/profile_parameter.t | 1 +
6 files changed, 53 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d936a344/traffic_ops/app/lib/Fixtures/Tenant.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Fixtures/Tenant.pm b/traffic_ops/app/lib/Fixtures/Tenant.pm
new file mode 100644
index 0000000..168e482
--- /dev/null
+++ b/traffic_ops/app/lib/Fixtures/Tenant.pm
@@ -0,0 +1,46 @@
+package Fixtures::Tenant;
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use Moose;
+extends 'DBIx::Class::EasyFixture';
+use namespace::autoclean;
+use Digest::SHA1 qw(sha1_hex);
+
+my %definition_for = (
+ ## id => 1
+ root_tenant_name => {
+ new => 'Tenant',
+ using => {
+ id => 10**9, #a large number not to confuse the id sequence
+ name => 'root',
+ active => 1,
+ parent_id => undef,
+ },
+ },
+);
+
+sub get_definition {
+ my ( $self, $name ) = @_;
+ return $definition_for{$name};
+}
+
+sub all_fixture_names {
+ # sort by db id to guarantee insert order
+ return (sort { $definition_for{$a}{using}{id} cmp $definition_for{$b}{using}{id} } keys %definition_for);
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d936a344/traffic_ops/app/lib/Test/TestHelper.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Test/TestHelper.pm b/traffic_ops/app/lib/Test/TestHelper.pm
index acb9399..b6d3174 100644
--- a/traffic_ops/app/lib/Test/TestHelper.pm
+++ b/traffic_ops/app/lib/Test/TestHelper.pm
@@ -37,6 +37,7 @@ use Fixtures::ProfileParameter;
use Fixtures::Role;
use Fixtures::Server;
use Fixtures::Status;
+use Fixtures::Tenant;
use Fixtures::TmUser;
use Fixtures::Type;
use Fixtures::Division;
@@ -103,6 +104,7 @@ sub load_core_data {
$self->reset_sequence_id();
+ $self->load_all_fixtures( Fixtures::Tenant->new($schema_values) );
$self->load_all_fixtures( Fixtures::Cdn->new($schema_values) );
$self->load_all_fixtures( Fixtures::Role->new($schema_values) );
$self->load_all_fixtures( Fixtures::TmUser->new($schema_values) );
@@ -153,6 +155,7 @@ sub unload_core_data {
$self->teardown($schema, 'Status');
$self->teardown($schema, 'Snapshot');
$self->teardown($schema, 'Cdn');
+ $self->teardown($schema, 'Tenant');
}
sub teardown {
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d936a344/traffic_ops/app/t/api/1.2/cachegroup.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/cachegroup.t b/traffic_ops/app/t/api/1.2/cachegroup.t
index a03b226..caa943e 100644
--- a/traffic_ops/app/t/api/1.2/cachegroup.t
+++ b/traffic_ops/app/t/api/1.2/cachegroup.t
@@ -37,6 +37,7 @@ Test::TestHelper->unload_core_data($schema);
# Load the test data up until 'cachegroup', because this test case creates
# them.
+Test::TestHelper->load_all_fixtures( Fixtures::Tenant->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::Cdn->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::Role->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::TmUser->new($schema_values) );
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d936a344/traffic_ops/app/t/api/1.2/federation_external.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/federation_external.t b/traffic_ops/app/t/api/1.2/federation_external.t
index e9959f6..2f2279f 100644
--- a/traffic_ops/app/t/api/1.2/federation_external.t
+++ b/traffic_ops/app/t/api/1.2/federation_external.t
@@ -39,6 +39,7 @@ my $schema_values = { schema => $schema, no_transactions => 1 };
#unload data for a clean test
Test::TestHelper->unload_core_data($schema);
+Test::TestHelper->load_all_fixtures( Fixtures::Tenant->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::Cdn->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::Role->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::TmUser->new($schema_values) );
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d936a344/traffic_ops/app/t/api/1.2/parameter.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/parameter.t b/traffic_ops/app/t/api/1.2/parameter.t
index 8845b19..0458f4c 100644
--- a/traffic_ops/app/t/api/1.2/parameter.t
+++ b/traffic_ops/app/t/api/1.2/parameter.t
@@ -38,6 +38,7 @@ Test::TestHelper->unload_core_data($schema);
# Load the test data up until 'cachegroup', because this test case creates
# them.
+Test::TestHelper->load_all_fixtures( Fixtures::Tenant->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::Cdn->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::Role->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::TmUser->new($schema_values) );
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/d936a344/traffic_ops/app/t/api/1.2/profile_parameter.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/profile_parameter.t b/traffic_ops/app/t/api/1.2/profile_parameter.t
index 9a1215b..dd3bf83 100644
--- a/traffic_ops/app/t/api/1.2/profile_parameter.t
+++ b/traffic_ops/app/t/api/1.2/profile_parameter.t
@@ -35,6 +35,7 @@ my $dbh = Schema->database_handle;
my $t = Test::Mojo->new('TrafficOps');
Test::TestHelper->unload_core_data($schema);
+Test::TestHelper->load_all_fixtures( Fixtures::Tenant->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::Cdn->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::Role->new($schema_values) );
Test::TestHelper->load_all_fixtures( Fixtures::TmUser->new($schema_values) );