-
Notifications
You must be signed in to change notification settings - Fork 0
TNTP-3729: generator for builtin go types #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,22 +8,54 @@ formatters: | |
- goimports | ||
|
||
linters: | ||
enable: | ||
- forbidigo | ||
- gocritic | ||
- lll | ||
- reassign | ||
- unconvert | ||
- gosec | ||
- errorlint | ||
- godot | ||
- revive | ||
- testpackage | ||
- unused | ||
default: all | ||
|
||
disable: | ||
- dupl | ||
- cyclop | ||
- wsl | ||
- nlreturn | ||
- ireturn | ||
- wrapcheck | ||
|
||
exclusions: | ||
rules: | ||
- path-except: cmd/generator/*.go | ||
linters: | ||
- forbidigo | ||
- gochecknoglobals | ||
Comment on lines
+21
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. |
||
|
||
settings: | ||
godot: | ||
scope: all | ||
lll: | ||
line-length: 120 | ||
tab-width: 4 | ||
wsl_v5: | ||
allow-first-in-block: true | ||
allow-whole-block: false | ||
branch-max-lines: 2 | ||
case-max-lines: 0 | ||
default: all | ||
disable: | ||
- return | ||
- assign-exclusive | ||
- assign-expr | ||
Comment on lines
+40
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, add comments: why do we disable the checks? After a while, it's not clear. |
||
depguard: | ||
rules: | ||
main: | ||
files: | ||
- "$all" | ||
- "!$test" | ||
allow: | ||
- $gostd | ||
- "github.com/vmihailenco/msgpack/v5" | ||
- "golang.org/x/text" | ||
test: | ||
files: | ||
- "$test" | ||
allow: | ||
- $gostd | ||
- "github.com/stretchr/testify" | ||
- "github.com/vmihailenco/msgpack/v5" | ||
- "github.com/tarantool/go-option" |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,6 +10,10 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release. | |||||
|
||||||
### Added | ||||||
|
||||||
* Implemented optional types for builtin go types int*, uint*, float*, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See: https://keepachangelog.com/en/1.0.0/
Suggested change
|
||||||
bytes, string, bool. | ||||||
|
||||||
|
||||||
### Changed | ||||||
|
||||||
### Fixed | ||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package option_test | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/vmihailenco/msgpack/v5" | ||
|
||
"github.com/tarantool/go-option" | ||
) | ||
|
||
func TestOptionalBool(t *testing.T) { | ||
t.Parallel() | ||
|
||
var buf bytes.Buffer | ||
|
||
enc := msgpack.NewEncoder(&buf) | ||
dec := msgpack.NewDecoder(&buf) | ||
|
||
someBool := option.SomeBool(true) | ||
assert.True(t, someBool.IsSome(), "Expected IsPresent() to return true") | ||
require.NoError(t, someBool.EncodeMsgpack(enc)) | ||
|
||
var shouldBeSomeBool option.Bool | ||
require.NoError(t, shouldBeSomeBool.DecodeMsgpack(dec)) | ||
assert.True(t, shouldBeSomeBool.IsSome(), "Expected IsPresent() to return true") | ||
assert.Equal(t, someBool.Unwrap(), shouldBeSomeBool.Unwrap(), "Expected Value() to return the same value") | ||
|
||
emptyBool := option.NoneBool() | ||
assert.False(t, emptyBool.IsSome(), "Expected IsPresent() to return false") | ||
require.NoError(t, emptyBool.EncodeMsgpack(enc)) | ||
|
||
var shouldBeEmptyBool option.Bool | ||
require.NoError(t, shouldBeEmptyBool.DecodeMsgpack(dec)) | ||
assert.False(t, shouldBeEmptyBool.IsSome(), "Expected IsPresent() to return false") | ||
} | ||
Comment on lines
+14
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, split the test into 3 or 4 tests by AAA-pattern: https://medium.com/@pjbgf/title-testing-code-ocd-and-the-aaa-pattern-df453975ab80 Here we have a one tests for multiple test cases. This is a bad example for future developers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like we don't cover all methods in the tests. MustGet as example. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package option_test | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/vmihailenco/msgpack/v5" | ||
|
||
"github.com/tarantool/go-option" | ||
) | ||
|
||
func TestOptionalBytes(t *testing.T) { | ||
t.Parallel() | ||
|
||
var buf bytes.Buffer | ||
|
||
enc := msgpack.NewEncoder(&buf) | ||
dec := msgpack.NewDecoder(&buf) | ||
|
||
someBytes := option.SomeBytes([]byte("1234")) | ||
assert.True(t, someBytes.IsSome(), "Expected IsPresent() to return true") | ||
require.NoError(t, someBytes.EncodeMsgpack(enc)) | ||
|
||
var shouldBeSomeBytes option.Bytes | ||
require.NoError(t, shouldBeSomeBytes.DecodeMsgpack(dec)) | ||
assert.True(t, shouldBeSomeBytes.IsSome(), "Expected IsPresent() to return true") | ||
assert.Equal(t, someBytes.Unwrap(), shouldBeSomeBytes.Unwrap(), "Expected Value() to return the same value") | ||
|
||
emptyBytes := option.NoneBytes() | ||
assert.False(t, emptyBytes.IsSome(), "Expected IsPresent() to return false") | ||
require.NoError(t, emptyBytes.EncodeMsgpack(enc)) | ||
|
||
var shouldBeEmptyBytes option.Bytes | ||
require.NoError(t, shouldBeEmptyBytes.DecodeMsgpack(dec)) | ||
assert.False(t, shouldBeEmptyBytes.IsSome(), "Expected IsPresent() to return false") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add comments: why do we disable the checks? After a while, it's not clear.