Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4ffb02be
Commit
4ffb02be
authored
Jul 18, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
3d795626
9246fd57
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
2 deletions
+35
-2
doc/development/go_guide/index.md
doc/development/go_guide/index.md
+35
-2
No files found.
doc/development/go_guide/index.md
View file @
4ffb02be
...
@@ -129,17 +129,50 @@ deploy a new pod, migrating the data automatically.
...
@@ -129,17 +129,50 @@ deploy a new pod, migrating the data automatically.
## Testing
## Testing
### Testing frameworks
We should not use any specific library or framework for testing, as the
We should not use any specific library or framework for testing, as the
[
standard library
](
https://golang.org/pkg/
)
provides already everything to get
[
standard library
](
https://golang.org/pkg/
)
provides already everything to get
started. For example, some external dependencies might be worth considering in
started. If there is a need for more sophisticated testing tools, the following
case we decide to use a specific library or framework:
external dependencies might be worth considering in case we decide to use a specific
library or framework:
-
[
Testify
](
https://github.com/stretchr/testify
)
-
[
Testify
](
https://github.com/stretchr/testify
)
-
[
httpexpect
](
https://github.com/gavv/httpexpect
)
-
[
httpexpect
](
https://github.com/gavv/httpexpect
)
### Subtests
Use
[
subtests
](
https://blog.golang.org/subtests
)
whenever possible to improve
Use
[
subtests
](
https://blog.golang.org/subtests
)
whenever possible to improve
code readability and test output.
code readability and test output.
### Better output in tests
When comparing expected and actual values in tests, use
[
testify/require.Equal
](
https://godoc.org/github.com/stretchr/testify/require#Equal
)
,
[
testify/require.EqualError
](
https://godoc.org/github.com/stretchr/testify/require#EqualError
)
,
[
testify/require.EqualValues
](
https://godoc.org/github.com/stretchr/testify/require#EqualValues
)
,
and others to improve readability when comparing structs, errors,
large portions of text, or JSON documents:
```
go
type
TestData
struct
{
// ...
}
func
FuncUnderTest
()
TestData
{
// ...
}
func
Test
(
t
*
testing
.
T
)
{
t
.
Run
(
"FuncUnderTest"
,
func
(
t
*
testing
.
T
)
{
want
:=
TestData
{}
got
:=
FuncUnderTest
()
require
.
Equal
(
t
,
want
,
got
)
// note that expected value comes first, then comes the actual one ("diff" semantics)
})
}
```
### Benchmarks
### Benchmarks
Programs handling a lot of IO or complex operations should always include
Programs handling a lot of IO or complex operations should always include
...
...
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