Пример #1
0
func Test_GetProvider(t *testing.T) {
	a := assert.New(t)

	provider := &faux.Provider{}
	goth.UseProviders(provider)

	p, err := goth.GetProvider(provider.Name())
	a.NoError(err)
	a.Equal(p, provider)

	p, err = goth.GetProvider("unknown")
	a.Error(err)
	a.Equal(err.Error(), "no provider for unknown exists")
	goth.ClearProviders()
}
Пример #2
0
func getPlatform(c *echo.Context) (goth.Provider, error) {

	platformName, err := getPlatformName(c)
	if err != nil {
		return nil, err
	}
	platform, err := goth.GetProvider(platformName)
	if err != nil {
		return nil, echo.NewHTTPError(http.StatusNotImplemented, "Platform unavailable.")
	}
	return platform, nil
}