Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
rednerd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orus-io
rednerd
Commits
cd4c1160
Commit
cd4c1160
authored
4 months ago
by
Axel Prel
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
2f2261ad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
restapi/handlers/account-template-preview_test.go
+46
-0
46 additions, 0 deletions
restapi/handlers/account-template-preview_test.go
testutils/apitester/apitester_template_management.go
+17
-0
17 additions, 0 deletions
testutils/apitester/apitester_template_management.go
with
63 additions
and
0 deletions
restapi/handlers/account-template-preview_test.go
0 → 100644
+
46
−
0
View file @
cd4c1160
package
handlers_test
import
(
"testing"
"orus.io/orus-io/rednerd/models"
"orus.io/orus-io/rednerd/testutils"
"orus.io/orus-io/rednerd/testutils/apitester"
)
func
TestAccountTemplatePreview
(
t
*
testing
.
T
)
{
log
:=
testutils
.
GetLogger
(
t
)
ctx
,
cancel
:=
testutils
.
GetContext
(
t
)
ctx
=
log
.
WithContext
(
ctx
)
defer
cancel
()
tester
:=
apitester
.
NewAPITester
(
ctx
,
t
,
nil
)
defer
tester
.
Close
()
tester
.
Login
(
"admin"
,
"admin"
)
user
:=
"janedoe"
tester
.
CreateUser
(
user
,
user
)
tester
.
Logout
()
tester
.
Login
(
"janedoe"
,
"janedoe"
)
defer
tester
.
Logout
()
tName
:=
"hello"
tmpl
:=
models
.
Template
{
Account
:
user
,
Name
:
tName
,
Language
:
"mustache"
,
Produces
:
"text/plain"
,
BodyFormat
:
"text"
,
Body
:
"Hello {{name}}!"
,
}
var
respTemplate
*
models
.
Template
tester
.
CreateTemplate
(
user
,
&
tmpl
,
respTemplate
)
t
.
Run
(
"basic"
,
func
(
t
*
testing
.
T
)
{
tester
.
Preview
(
user
,
tName
)
})
}
This diff is collapsed.
Click to expand it.
testutils/apitester/apitester_template_management.go
+
17
−
0
View file @
cd4c1160
...
@@ -67,6 +67,23 @@
...
@@ -67,6 +67,23 @@
r
.
JSON
(
result
)
r
.
JSON
(
result
)
}
}
// Preview returns the PNG preview of the template.
func
(
tester
*
APITester
)
Preview
(
username
,
templateName
string
,
)
{
apitest
:=
tester
.
APITest
(
"preview"
)
if
tester
.
debug
{
apitest
=
apitest
.
Debug
()
}
r
:=
apitest
.
Get
(
"/api/v1/render/"
+
username
+
"/"
+
templateName
+
"/preview.png"
)
.
Expect
(
tester
.
t
)
.
Status
(
http
.
StatusOK
)
.
End
()
tester
.
Logger
.
Info
()
.
Msgf
(
"result %#v"
,
r
)
}
// Renderlogs gives us a csv document containing the
// Renderlogs gives us a csv document containing the
// Rendering data for invoicing.
// Rendering data for invoicing.
func
(
tester
*
APITester
)
RenderLogs
(
func
(
tester
*
APITester
)
RenderLogs
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment