generated from OtusGolang/home_work
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Hw10 program optimization #10
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
779d970
HW09. refactoring func validate. add rules.FieldRules
2edccb6
hw09. rules.ParseRulesTag function
e4f82b3
HW09. devel validate and validateField.devel rules.FieldRulesByTag an…
b866dd9
HW09. refactoring packcge rule
da64bb6
HW09. refactoring and test funcValidation
d844c29
HW09. refactor func TestParseRulesTag
c5d1dc2
HW09. refactoring rule_test.go
9522e30
HW09. refactoring errors for validator function, tests for string regexp
04d2556
hw09. rules for int and tests
c4294bb
hw09. removed kind checking for validation function and tests for the…
0d06673
hw09. for golangci-lint
bbdd458
hw09. refactor validate.go, add vaildate Slice
5ad3b5a
hw09. add validate nested struct
dd6eabd
hw09. add tests for Validate
d532980
hw09. add tests
f8e33ee
hw09. package rules full cover
6a10595
hw09. validator test cover 77
fb21e58
hw09. linter check
a154d26
hw09. add tag 'nested' and test
e9a47d0
HW09. Validator tests
4454c88
HW09 is completed
a829e48
HW10 is completed
804a6ce
HW10 linter
d8a90f2
HW10 tests
ac0de95
HW10 mod tidy
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
module github.com/DimVlas/otus_hw/hw09_struct_validator | ||
|
||
go 1.22 | ||
|
||
require github.com/stretchr/testify v1.9.0 | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package rules | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestValidationError(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
data ValidationError | ||
exp string | ||
}{ | ||
{ | ||
name: "ValidationError_full", | ||
data: ValidationError{ | ||
Field: "field", | ||
Err: errors.New("test error"), | ||
}, | ||
exp: "field: test error", | ||
}, | ||
{ | ||
name: "ValidationError_without_field", | ||
data: ValidationError{ | ||
Field: "", | ||
Err: errors.New("test error"), | ||
}, | ||
exp: "test error", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
s := test.data.Error() | ||
|
||
require.Equal(t, test.exp, s) | ||
}) | ||
} | ||
} | ||
|
||
func TestValidationErrors(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
data ValidationErrors | ||
exp string | ||
}{ | ||
{ | ||
name: "ValidationErrors_full", | ||
data: ValidationErrors{ | ||
{ | ||
Field: "f1", | ||
Err: errors.New("error1"), | ||
}, | ||
{ | ||
Field: "f2", | ||
Err: errors.New("error2"), | ||
}, | ||
}, | ||
exp: "field f1: error1\nfield f2: error2\n", | ||
}, | ||
{ | ||
name: "ValidationErrors_empty", | ||
data: ValidationErrors{}, | ||
exp: "", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
s := test.data.Error() | ||
|
||
require.Equal(t, test.exp, s) | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Очень важно, чтобы PR содержал только файлы, относящиеся к текущему ДЗ