Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
llm-server-test
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
llm-server-test
Commits
4eacf0ee
Commit
4eacf0ee
authored
Feb 02, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update resp data
parent
f8d7992e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
12 deletions
+64
-12
BaseController.go
controllers/BaseController.go
+2
-2
default_test.go
tests/default_test.go
+62
-10
No files found.
controllers/BaseController.go
View file @
4eacf0ee
...
...
@@ -13,10 +13,10 @@ func (d *BaseController) ResponseInfo(code int, msg interface{}, result interfac
switch
code
{
case
500
:
logs
.
Error
(
msg
,
result
)
d
.
Data
[
"json"
]
=
map
[
string
]
interface
{}{
"code"
:
"500"
,
"msg"
:
msg
,
"
content
"
:
result
}
d
.
Data
[
"json"
]
=
map
[
string
]
interface
{}{
"code"
:
"500"
,
"msg"
:
msg
,
"
data
"
:
result
}
case
200
:
logs
.
Info
(
msg
,
result
)
d
.
Data
[
"json"
]
=
map
[
string
]
interface
{}{
"code"
:
"200"
,
"msg"
:
msg
,
"
content
"
:
result
}
d
.
Data
[
"json"
]
=
map
[
string
]
interface
{}{
"code"
:
"200"
,
"msg"
:
msg
,
"
data
"
:
result
}
}
d
.
ServeJSON
()
}
tests/default_test.go
View file @
4eacf0ee
package
test
import
(
"fmt"
"net/http"
"net/http/httptest"
"testing"
"runtime"
"path/filepath"
"runtime"
"sync"
"testing"
"time"
_
"token-uri/routers"
"github.com/astaxie/beego"
...
...
@@ -14,11 +17,10 @@ import (
func
init
()
{
_
,
file
,
_
,
_
:=
runtime
.
Caller
(
0
)
apppath
,
_
:=
filepath
.
Abs
(
filepath
.
Dir
(
filepath
.
Join
(
file
,
".."
+
string
(
filepath
.
Separator
))))
apppath
,
_
:=
filepath
.
Abs
(
filepath
.
Dir
(
filepath
.
Join
(
file
,
".."
+
string
(
filepath
.
Separator
))))
beego
.
TestBeegoInit
(
apppath
)
}
// TestBeego is a sample to run an endpoint test
func
TestBeego
(
t
*
testing
.
T
)
{
r
,
_
:=
http
.
NewRequest
(
"GET"
,
"/"
,
nil
)
...
...
@@ -28,12 +30,62 @@ func TestBeego(t *testing.T) {
beego
.
Trace
(
"testing"
,
"TestBeego"
,
"Code[%d]
\n
%s"
,
w
.
Code
,
w
.
Body
.
String
())
Convey
(
"Subject: Test Station Endpoint
\n
"
,
t
,
func
()
{
Convey
(
"Status Code Should Be 200"
,
func
()
{
So
(
w
.
Code
,
ShouldEqual
,
200
)
})
Convey
(
"The Result Should Not Be Empty"
,
func
()
{
So
(
w
.
Body
.
Len
(),
ShouldBeGreaterThan
,
0
)
})
Convey
(
"Status Code Should Be 200"
,
func
()
{
So
(
w
.
Code
,
ShouldEqual
,
200
)
})
Convey
(
"The Result Should Not Be Empty"
,
func
()
{
So
(
w
.
Body
.
Len
(),
ShouldBeGreaterThan
,
0
)
})
})
}
func
TestGoRoutine
(
t
*
testing
.
T
)
{
handlerIns
:=
&
handler
{
wg
:
&
sync
.
WaitGroup
{},
}
msg
:=
make
(
chan
int
,
0
)
for
i
:=
0
;
i
<
2
;
i
++
{
go
handlerMsg
(
handlerIns
,
msg
,
i
)
}
for
{
i
:=
10
if
i
%
10
==
0
{
time
.
Sleep
(
time
.
Second
*
2
)
msg
<-
1
}
i
++
}
}
type
handler
struct
{
wg
*
sync
.
WaitGroup
}
func
handlerMsg
(
h
*
handler
,
msg
chan
int
,
count
int
)
{
for
{
fmt
.
Println
(
"xxxx:"
,
count
)
select
{
case
rev
:=
<-
msg
:
{
if
rev
==
1
{
fmt
.
Println
(
"exec xxxx:"
,
count
)
go
func
(
h
*
handler
)
{
h
.
wg
.
Add
(
1
)
h
.
handlerXXX
()
h
.
wg
.
Wait
()
fmt
.
Println
(
"exec task"
)
}(
h
)
continue
}
}
}
}
}
func
(
h
*
handler
)
handlerXXX
()
{
defer
h
.
wg
.
Done
()
time
.
Sleep
(
time
.
Second
*
2
)
fmt
.
Println
(
"wg done"
)
}
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