Skip to content
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

refactor: rename OptionUnsafe&OptionGeneric to OptXxx #29

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func Mock(target interface{}, opt ...optionFn) *MockBuilder {
// MockUnsafe has the full ability of the Mock function and removes some security restrictions. This is an alternative
// when the Mock function fails. It may cause some unknown problems, so we recommend using Mock under normal conditions.
func MockUnsafe(target interface{}) *MockBuilder {
return Mock(target, OptionUnsafe)
return Mock(target, OptUnsafe)
}

func (builder *MockBuilder) resetCondition() *MockBuilder {
Expand Down
2 changes: 1 addition & 1 deletion mock_generics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
package mockey

func MockGeneric(target interface{}) *MockBuilder {
return Mock(target, OptionGeneric)
return Mock(target, OptGeneric)
}
4 changes: 2 additions & 2 deletions mock_generics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func TestGeneric(t *testing.T) {
convey.So(sum[float64](1, 2), convey.ShouldEqual, 888)
})
PatchConvey("type", func() {
Mock((generic[int]).Value, OptionGeneric).Return(999).Build()
Mock(GetMethod(generic[string]{}, "Value2"), OptionGeneric).To(func() string {
Mock((generic[int]).Value, OptGeneric).Return(999).Build()
Mock(GetMethod(generic[string]{}, "Value2"), OptGeneric).To(func() string {
return "mock"
}).Build()
gi := generic[int]{a: 123}
Expand Down
4 changes: 2 additions & 2 deletions option.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ type option struct {

type optionFn func(*option)

var OptionUnsafe optionFn = func(o *option) {
func OptUnsafe(o *option) {
o.unsafe = true
}

var OptionGeneric optionFn = func(o *option) {
func OptGeneric(o *option) {
o.generic = true
}

Expand Down