-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making lib/backend/client.getFactory public
Mainly to allow writing "wrapper" custom backends, see eg #278 (comment) Signed-off-by: Jean Rouge <[email protected]>
- Loading branch information
Showing
3 changed files
with
36 additions
and
3 deletions.
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
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,32 @@ | ||
package backend | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRegisterAndGetFactory(t *testing.T) { | ||
t.Run("round-trip", func(t *testing.T) { | ||
name := "dummy" | ||
factory := &dummyFactory{} | ||
|
||
Register(name, factory) | ||
roundTrip, err := GetFactory(name) | ||
|
||
assert.NoError(t, err) | ||
assert.Equal(t, factory, roundTrip) | ||
}) | ||
|
||
t.Run("GetFactory errors out on missing factory", func(t *testing.T) { | ||
_, err := GetFactory("i_dont_exist") | ||
|
||
assert.Error(t, err) | ||
}) | ||
} | ||
|
||
type dummyFactory struct{} | ||
|
||
func (f *dummyFactory) Create(config interface{}, authConfig interface{}) (Client, error) { | ||
return nil, nil | ||
} |
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