./ct_report/coverage/mongoose_graphql_mnesia_admin_mutation.COVER.html

1 -module(mongoose_graphql_mnesia_admin_mutation).
2 -behaviour(mongoose_graphql).
3
4 -export([execute/4]).
5
6 -import(mongoose_graphql_helper, [make_error/2, make_error/3]).
7
8 -ignore_xref([execute/4]).
9
10 -include("../mongoose_graphql_types.hrl").
11
12 execute(_Ctx, mnesia, <<"setMaster">>, #{<<"node">> := Node}) ->
13
:-(
case mnesia_api:set_master(Node) of
14
:-(
{ok, _} -> {ok, "Master node set"};
15
:-(
Error -> make_error(Error, #{node => Node})
16 end;
17 execute(_Ctx, mnesia, <<"backup">>, #{<<"path">> := Path}) ->
18
:-(
case mnesia_api:backup_mnesia(binary_to_list(Path)) of
19
:-(
{ok, _} -> {ok, "Mnesia backup was successfully created"};
20
:-(
Error -> make_error(Error, #{path => Path})
21 end;
22 execute(_Ctx, mnesia, <<"changeNodename">>, #{<<"fromString">> := FromString,
23 <<"toString">> := ToString, <<"source">> := Source, <<"target">> := Target}) ->
24
:-(
case mnesia_api:mnesia_change_nodename(FromString, ToString,
25 binary_to_list(Source), binary_to_list(Target)) of
26
:-(
{ok, _} -> {ok, "Name of the node in the backup was successfully changed"};
27
:-(
Error -> make_error(Error, #{fromString => FromString, toString => ToString,
28 source => Source, target => Target})
29 end;
30 execute(_Ctx, mnesia, <<"restore">>, #{<<"path">> := Path}) ->
31
:-(
case mnesia_api:restore_mnesia(binary_to_list(Path)) of
32
:-(
{ok, _} -> {ok, "Mnesia was successfully restored"};
33
:-(
Error -> make_error(Error, #{path => Path})
34 end;
35 execute(_Ctx, mnesia, <<"dump">>, #{<<"path">> := Path}) ->
36
:-(
case mnesia_api:dump_mnesia(binary_to_list(Path)) of
37
:-(
{ok, _} -> {ok, "Mnesia successfully dumped"};
38
:-(
Error -> make_error(Error, #{path => Path})
39 end;
40 execute(_Ctx, mnesia, <<"dumpTable">>, #{<<"path">> := Path, <<"table">> := Table}) ->
41
:-(
case mnesia_api:dump_table(binary_to_list(Path), binary_to_list(Table)) of
42
:-(
{ok, _} -> {ok, "Mnesia table successfully dumped"};
43
:-(
Error -> make_error(Error, #{path => Path, table => Table})
44 end;
45 execute(_Ctx, mnesia, <<"load">>, #{<<"path">> := Path}) ->
46
:-(
case mnesia_api:load_mnesia(binary_to_list(Path)) of
47
:-(
{ok, _} -> {ok, "Mnesia was successfully loaded"};
48
:-(
Error -> make_error(Error, #{path => Path})
49 end;
50 execute(_Ctx, mnesia, <<"installFallback">>, #{<<"path">> := Path}) ->
51
:-(
case mnesia_api:install_fallback_mnesia(binary_to_list(Path)) of
52
:-(
{ok, _} -> {ok, "Fallback installed"};
53
:-(
Error -> make_error(Error, #{path => Path})
54 end.
Line Hits Source