From 373e7b33f93b1ad0a4f4acb51f18e13838da54bc Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Sun, 9 Apr 2023 23:40:49 +0200 Subject: [PATCH] test: allow tests to run without desc cache --- apps/emqx_dashboard/src/emqx_dashboard_desc_cache.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/emqx_dashboard/src/emqx_dashboard_desc_cache.erl b/apps/emqx_dashboard/src/emqx_dashboard_desc_cache.erl index 8fd6fe3d3..9d8d1905d 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard_desc_cache.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard_desc_cache.erl @@ -60,7 +60,7 @@ lookup(Lang, Namespace, Id, Tag) -> %% @doc Lookup the description of the configuration item from the given cache. lookup(EtsTab, Lang0, Namespace, Id, Tag) -> Lang = bin(Lang0), - case ets:lookup(EtsTab, {Lang, bin(Namespace), bin(Id), bin(Tag)}) of + try ets:lookup(EtsTab, {Lang, bin(Namespace), bin(Id), bin(Tag)}) of [{_, Desc}] -> Desc; [] when Lang =/= <<"en">> -> @@ -69,6 +69,11 @@ lookup(EtsTab, Lang0, Namespace, Id, Tag) -> _ -> %% undefined but not <<>> undefined + catch + error:badarg -> + %% schema is not initialized + %% most likely in test cases + undefined end. %% The desc files are of names like: