diff --git a/basculehttp/bearerTokenFactory.go b/basculehttp/bearerTokenFactory.go index 2b93f6b..ed1cea4 100644 --- a/basculehttp/bearerTokenFactory.go +++ b/basculehttp/bearerTokenFactory.go @@ -134,18 +134,3 @@ func ProvideBearerTokenFactory(configKey string, optional bool) fx.Option { ), ) } - -// ProvideResolver is a helper function for wiring up a Clortho Resolver -func ProvideResolver(key string, optional bool) fx.Option { - return fx.Provide( - fx.Annotated{ - Name: "key_resolver", - Target: func(in ...clortho.ResolverOption) (clortho.Resolver, error) { - if optional { - return nil, nil - } - return clortho.NewResolver(clortho.WithKeyIDTemplate(key)) - }, - }, - ) -} diff --git a/basculehttp/bearerTokenFactory_test.go b/basculehttp/bearerTokenFactory_test.go index 2d2821a..b2e1527 100644 --- a/basculehttp/bearerTokenFactory_test.go +++ b/basculehttp/bearerTokenFactory_test.go @@ -32,7 +32,6 @@ import ( "github.com/stretchr/testify/require" "github.com/xmidt-org/arrange" "github.com/xmidt-org/bascule" - "github.com/xmidt-org/clortho" "go.uber.org/fx" ) @@ -235,72 +234,72 @@ good: } } -func TestProvideResolver(t *testing.T) { - type In struct { - fx.In - R clortho.Resolver `name:"key_resolver"` - } +// func TestProvideResolver(t *testing.T) { +// type In struct { +// fx.In +// R clortho.Resolver `name:"key_resolver"` +// } - const yaml = ` -good: - factory: - uri: "http://test:1111/keys/{keyId}" - purpose: 0 - updateInterval: 604800000000000 -` - v := viper.New() - v.SetConfigType("yaml") - require.NoError(t, v.ReadConfig(strings.NewReader(yaml))) +// const yaml = ` +// good: +// factory: +// uri: "http://test:1111/keys/{keyId}" +// purpose: 0 +// updateInterval: 604800000000000 +// ` +// v := viper.New() +// v.SetConfigType("yaml") +// require.NoError(t, v.ReadConfig(strings.NewReader(yaml))) - goodResolver, err := clortho.NewResolver(clortho.WithKeyIDTemplate("good")) - require.Nil(t, err) +// goodResolver, err := clortho.NewResolver(clortho.WithKeyIDTemplate("good")) +// require.Nil(t, err) - tests := []struct { - description string - key string - optional bool - expectedResolver clortho.Resolver - expectedErr error - }{ - { - description: "Success", - key: "good", - optional: false, - expectedResolver: goodResolver, - }, - { - description: "Silent failure", - key: "bad", - optional: true, - }, - } - for _, tc := range tests { - t.Run(tc.description, func(t *testing.T) { - result := In{} - assert := assert.New(t) - require := require.New(t) - app := fx.New( - arrange.TestLogger(t), - arrange.ForViper(v), - ProvideResolver(tc.key, tc.optional), - fx.Invoke( - func(in In) { - result = in - }, - ), - ) - err := app.Err() +// tests := []struct { +// description string +// key string +// optional bool +// expectedResolver clortho.Resolver +// expectedErr error +// }{ +// { +// description: "Success", +// key: "good", +// optional: false, +// expectedResolver: goodResolver, +// }, +// { +// description: "Silent failure", +// key: "bad", +// optional: true, +// }, +// } +// for _, tc := range tests { +// t.Run(tc.description, func(t *testing.T) { +// result := In{} +// assert := assert.New(t) +// require := require.New(t) +// app := fx.New( +// arrange.TestLogger(t), +// arrange.ForViper(v), +// ProvideResolver(tc.key, tc.optional), +// fx.Invoke( +// func(in In) { +// result = in +// }, +// ), +// ) +// err := app.Err() - assert.Equal(tc.expectedResolver, result.R) - if tc.expectedErr == nil { - assert.NoError(err) - return - } - require.Error(err) - assert.True(strings.Contains(err.Error(), tc.expectedErr.Error()), - fmt.Errorf("error [%v] doesn't contain error [%v]", - err, tc.expectedErr), - ) - }) - } -} +// assert.Equal(tc.expectedResolver, result.R) +// if tc.expectedErr == nil { +// assert.NoError(err) +// return +// } +// require.Error(err) +// assert.True(strings.Contains(err.Error(), tc.expectedErr.Error()), +// fmt.Errorf("error [%v] doesn't contain error [%v]", +// err, tc.expectedErr), +// ) +// }) +// } +// }