Skip to content

Commit 1d15c59

Browse files
committed
Correctly find schema for rabbit application named "rabbitmq.schema"
1 parent 6dee656 commit 1d15c59

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/rabbit_ct_config_schema.erl

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@
2323
init_schemas(App, Config) ->
2424
DepsDir = ?config(erlang_mk_depsdir, Config),
2525
% Note: the schema for the rabbit app is named "rabbitmq.schema"
26-
RabbitSchema = filename:join([DepsDir, "rabbit", "priv", "schema", "rabbitmq.schema"]),
26+
RabbitSchemaInfo = {DepsDir, rabbit, "rabbitmq.schema"},
27+
RabbitSchema = find_app_schema(RabbitSchemaInfo),
2728
Schemas = case App of
2829
rabbit -> [RabbitSchema];
29-
_ -> [RabbitSchema, find_app_schema(App, DepsDir)]
30+
_ ->
31+
SchemaFileName = atom_to_list(App) ++ ".schema",
32+
SchemaInfo = {DepsDir, App, SchemaFileName},
33+
[RabbitSchema, find_app_schema(SchemaInfo)]
3034
end,
3135
ct:pal("Schemas ~p~n", [Schemas]),
3236
SchemaDir = filename:join(?config(data_dir, Config), "schema"),
@@ -45,21 +49,21 @@ init_schemas(App, Config) ->
4549
{conf_snippets, Snippets}
4650
]).
4751

48-
find_app_schema(App, DepsDir) ->
49-
Schema = get_schema_for([DepsDir, App, "priv"], App),
50-
does_schema_exist(filelib:is_regular(Schema), App, DepsDir, Schema, cont).
52+
find_app_schema({DepsDir, App, SchemaFileName}=Info) ->
53+
SchemaFile = get_schema_for([DepsDir, App], SchemaFileName),
54+
does_schema_exist(filelib:is_regular(SchemaFile), Info, SchemaFile, cont).
5155

52-
does_schema_exist(true, _App, _DepsDir, Schema, _) ->
53-
Schema;
54-
does_schema_exist(false, App, _DepsDir, _Schema, stop) ->
56+
does_schema_exist(true, _Info, SchemaFile, _) ->
57+
SchemaFile;
58+
does_schema_exist(false, {_, App, _}, _SchemaFile, stop) ->
5559
ct:fail("Could not find schema for app: ~p~n", [App]);
56-
does_schema_exist(false, App, DepsDir, _Schema, cont) ->
60+
does_schema_exist(false, {DepsDir, _, SchemaFileName}=Info, _SchemaFile, cont) ->
5761
% If not in umbrella, priv will be at ../priv
58-
Schema = get_schema_for([DepsDir, "..", "priv"], App),
59-
does_schema_exist(filelib:is_regular(Schema), App, DepsDir, Schema, stop).
62+
SchemaFile = get_schema_for([DepsDir, ".."], SchemaFileName),
63+
does_schema_exist(filelib:is_regular(SchemaFile), Info, SchemaFile, stop).
6064

61-
get_schema_for(Prefix, App) ->
62-
filename:join(Prefix ++ ["schema", atom_to_list(App) ++ ".schema"]).
65+
get_schema_for(Prefix, SchemaFileName) ->
66+
filename:join(Prefix ++ ["priv", "schema", SchemaFileName]).
6367

6468
copy_to(File, Dir) ->
6569
BaseName = filename:basename(File),

0 commit comments

Comments
 (0)