Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
3109bb13
Commit
3109bb13
authored
Mar 21, 2018
by
Sander van Harmelen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests
parent
eb011b7a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
41 deletions
+36
-41
validate_test.go
validate_test.go
+36
-41
No files found.
validate_test.go
View file @
3109bb13
...
...
@@ -7,58 +7,53 @@ import (
"testing"
)
// TODO: better test posting empty string
func
TestValidate
(
t
*
testing
.
T
)
{
validContent
:=
`
build1:
stage: build
script:
- echo "Do your build here"`
invalidContent
:=
`
build1:
- echo "Do your build here"`
validRes
:=
`{
"status": "valid",
"errors": []
}`
invalidRes
:=
`{
"status": "invalid",
"errors": [
"error message when content is invalid"
]
}`
wantValid
:=
&
LintResult
{
Status
:
"valid"
,
Errors
:
[]
string
{},
}
wantInvalid
:=
&
LintResult
{
Status
:
"invalid"
,
Errors
:
[]
string
{
"error message when content is invalid"
},
}
testCases
:=
[]
struct
{
desc
string
content
string
res
string
want
*
LintResult
desc
ription
string
content
string
res
ponse
string
want
*
LintResult
}{
{
"valid"
,
validContent
,
validRes
,
wantValid
},
{
"invalid"
,
invalidContent
,
invalidRes
,
wantInvalid
},
{
description
:
"valid"
,
content
:
`
build1:
stage: build
script:
- echo "Do your build here"`
,
response
:
`{
"status": "valid",
"errors": []
}`
,
want
:
&
LintResult
{
Status
:
"valid"
,
Errors
:
[]
string
{},
},
},
{
description
:
"invalid"
,
content
:
`
build1:
- echo "Do your build here"`
,
response
:
`{
"status": "invalid",
"errors": ["error message when content is invalid"]
}`
,
want
:
&
LintResult
{
Status
:
"invalid"
,
Errors
:
[]
string
{
"error message when content is invalid"
},
},
},
}
for
_
,
tc
:=
range
testCases
{
t
.
Run
(
tc
.
desc
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
desc
ription
,
func
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/ci/lint"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
fmt
.
Fprintf
(
w
,
tc
.
res
)
fmt
.
Fprintf
(
w
,
tc
.
res
ponse
)
})
got
,
_
,
err
:=
client
.
Validate
.
Lint
(
tc
.
content
)
...
...
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