Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nginx-redirector
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
nginx-redirector
Commits
44f1a1a5
Commit
44f1a1a5
authored
Apr 14, 2022
by
Soldatoff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set up tests for new codeSet up tests for new code
parent
4645e70c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
nginx-redirector.spec
.gear/nginx-redirector.spec
+4
-1
test.yaml
redirector/tests/test.yaml
+2
-1
generators.py
redirector/utils/generators.py
+15
-6
No files found.
.gear/nginx-redirector.spec
View file @
44f1a1a5
# TODO:
%def_without test
%define biname nginx-redirector
Name: nginx-redirector
...
...
@@ -50,6 +49,10 @@ mkdir -p %buildroot/var/log/%biname
install -pD -m644 nginx-redirector.service %buildroot%systemd_unitdir/nginx-redirector.service
%check
DIR=$(pwd)
env -i CONFIG_DIR=$DIR/redirector/tests/nginx_test_case/location-includes \
CONFIG=$DIR/redirector/tests/test.yaml \
MAPS_DIR=$DIR/redirector/tests/nginx_test_case/maps \
%python3_test
%files
...
...
redirector/tests/test.yaml
View file @
44f1a1a5
projects
:
-
map
:
.
/test.map
-
map
:
redirector/tests
/test.map
prefix
:
/test
name
:
/
redirector/utils/generators.py
View file @
44f1a1a5
...
...
@@ -26,7 +26,7 @@ class Generator:
def
generate
(
self
,
redirects_data
,
project_name
,
arg_map
=
None
):
arg
=
self
.
get_essential
(
arg_map
)
redirects_map
=
self
.
map_gen
.
generate_map
(
redirects_data
[
0
],
arg
)
redirects_with_options
=
self
.
map_gen
.
generate_opt_map
(
redirects_data
[
1
],
arg
[
"project_name"
])
#need test
redirects_with_options
=
self
.
map_gen
.
generate_opt_map
(
redirects_data
[
1
],
arg
)
conf_data
=
self
.
conf_gen
.
generate_config
(
arg
[
"project_name"
],
[
code
for
code
,
data
in
redirects_with_options
],
arg
[
"prefix"
])
maps_dir
,
config_dir
=
self
.
get_conf_dirs
()
...
...
@@ -75,17 +75,26 @@ class MapGenerator:
data
+=
self
.
endline
return
data
def
generate_opt_map
(
self
,
redirect_dict
,
project_name
):
def
generate_opt_map
(
self
,
redirect_dict
,
arg
):
result
=
[]
for
code
,
redirects
in
redirect_dict
.
items
():
if
code
==
"301"
:
code
=
"permanent"
data
=
self
.
opt_start_line
%
(
arg
[
"project_name"
],
code
)
for
arg1
,
arg2
in
redirects
:
data
+=
"
\n\t
%
s
\t
%
s;"
%
(
arg
[
"prefix"
]
+
arg1
,
arg2
)
data
+=
self
.
endline
elif
code
==
"302"
:
code
=
"redirect"
data
=
self
.
opt_start_line
%
(
project_name
,
code
)
for
arg1
,
arg2
in
redirects
:
data
+=
"
\n\t
%
s
\t
%
s;"
%
(
arg1
,
arg2
)
data
+=
self
.
endline
data
=
self
.
opt_start_line
%
(
arg
[
"project_name"
],
code
)
for
arg1
,
arg2
in
redirects
:
data
+=
"
\n\t
%
s
\t
%
s;"
%
(
arg
[
"prefix"
]
+
arg1
,
arg
[
"prefix"
]
+
arg2
)
data
+=
self
.
endline
elif
code
==
"status=301"
:
data
=
self
.
opt_start_line
%
(
arg
[
"project_name"
],
code
)
for
arg1
,
arg2
in
redirects
:
data
+=
"
\n\t
%
s
\t
%
s;"
%
(
arg
[
"prefix"
]
+
arg1
,
arg
[
"prefix"
]
+
arg2
)
data
+=
self
.
endline
result
.
append
((
code
,
data
))
return
result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment