From 40faa31241b725df56a47b044f728eb521006400 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Fri, 30 Jul 2021 10:08:36 +0200 Subject: [PATCH] test(authz): no need to mock emqx_config --- apps/emqx_authz/test/emqx_authz_http_SUITE.erl | 8 +------- apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl | 6 ------ apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl | 7 ------- apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl | 6 ------ apps/emqx_authz/test/emqx_authz_redis_SUITE.erl | 6 ------ 5 files changed, 1 insertion(+), 32 deletions(-) diff --git a/apps/emqx_authz/test/emqx_authz_http_SUITE.erl b/apps/emqx_authz/test/emqx_authz_http_SUITE.erl index 210a9e7cc..f387be77a 100644 --- a/apps/emqx_authz/test/emqx_authz_http_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_http_SUITE.erl @@ -30,12 +30,7 @@ groups() -> init_per_suite(Config) -> meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]), - meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ), - - %% important! let emqx_schema include the current app! - meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]), - meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ), - meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end), + meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end), ok = emqx_ct_helpers:start_apps([emqx_authz]), @@ -55,7 +50,6 @@ init_per_suite(Config) -> end_per_suite(_Config) -> emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]), - meck:unload(emqx_schema), meck:unload(emqx_resource). %%------------------------------------------------------------------------------ diff --git a/apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl b/apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl index b5453c0ff..a5f59ac64 100644 --- a/apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl @@ -29,11 +29,6 @@ groups() -> []. init_per_suite(Config) -> - %% important! let emqx_schema include the current app! - meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]), - meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ), - meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end), - meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]), meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end), @@ -56,7 +51,6 @@ init_per_suite(Config) -> end_per_suite(_Config) -> emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]), - meck:unload(emqx_schema), meck:unload(emqx_resource). -define(RULE1,[#{<<"topics">> => [<<"#">>], diff --git a/apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl b/apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl index 310b54025..050234478 100644 --- a/apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl @@ -29,15 +29,9 @@ groups() -> []. init_per_suite(Config) -> - meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]), meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ), - %% important! let emqx_schema include the current app! - meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]), - meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ), - meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end), - ok = emqx_ct_helpers:start_apps([emqx_authz]), ok = emqx_config:update([zones, default, authorization, cache, enable], false), @@ -59,7 +53,6 @@ init_per_suite(Config) -> end_per_suite(_Config) -> emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]), - meck:unload(emqx_schema), meck:unload(emqx_resource). -define(COLUMNS, [ <<"ipaddress">> diff --git a/apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl b/apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl index a3312be58..439dce14f 100644 --- a/apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl @@ -32,11 +32,6 @@ init_per_suite(Config) -> meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]), meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ), - %% important! let emqx_schema include the current app! - meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]), - meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ), - meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end), - ok = emqx_ct_helpers:start_apps([emqx_authz]), ok = emqx_config:update([zones, default, authorization, cache, enable], false), @@ -57,7 +52,6 @@ init_per_suite(Config) -> end_per_suite(_Config) -> emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]), - meck:unload(emqx_schema), meck:unload(emqx_resource). -define(COLUMNS, [ {column, <<"ipaddress">>, meck, meck, meck, meck, meck, meck, meck} diff --git a/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl b/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl index ed053381c..7c7990dbf 100644 --- a/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl @@ -32,11 +32,6 @@ init_per_suite(Config) -> meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]), meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ), - %% important! let emqx_schema include the current app! - meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]), - meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ), - meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end), - ok = emqx_ct_helpers:start_apps([emqx_authz]), ok = emqx_config:update([zones, default, authorization, cache, enable], false), @@ -56,7 +51,6 @@ init_per_suite(Config) -> end_per_suite(_Config) -> emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]), - meck:unload(emqx_schema), meck:unload(emqx_resource). -define(RULE1, [<<"test/%u">>, <<"publish">>]).