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

Mark GinI18n recievers as public #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chivincent
Copy link

Why?

For testing, users could mock GinI18n implementation, but they cannot do.

c, _ := gin.CreateTestContext(httptest.NewRecorder())
c.Set("i18n", &mockedGinI18N{})

if i18n.MustGetMessage(c, "hello_world") != "hello world" {
    t.Fatal()
}

However, the GinI18n interface defines 4 receivers:

getMessage(context *gin.Context, param interface{}) (string, error)
mustGetMessage(context *gin.Context, param interface{}) string
setBundle(cfg *BundleCfg)
setGetLngHandler(handler GetLngHandler)

Users cannot define mockedGinI18N in their code, because GinI18n has non-exported method.

How?

In this PR, I fixed that GinI18n interface receivers with public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant