pkg/plugins: TestGet(): use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
e1ad4aa002
commit
0f7bf67f83
1 changed files with 23 additions and 17 deletions
|
@ -64,27 +64,33 @@ func TestGet(t *testing.T) {
|
|||
p.Manifest = &Manifest{Implements: []string{fruitImplements}}
|
||||
storage.plugins[fruitPlugin] = p
|
||||
|
||||
plugin, err := Get(fruitPlugin, fruitImplements)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p.Name() != plugin.Name() {
|
||||
t.Fatalf("No matching plugin with name %s found", plugin.Name())
|
||||
}
|
||||
if plugin.Client() != nil {
|
||||
t.Fatal("expected nil Client but found one")
|
||||
}
|
||||
if !plugin.IsV1() {
|
||||
t.Fatal("Expected true for V1 plugin")
|
||||
}
|
||||
t.Run("success", func(t *testing.T) {
|
||||
plugin, err := Get(fruitPlugin, fruitImplements)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p.Name() != plugin.Name() {
|
||||
t.Errorf("no matching plugin with name %s found", plugin.Name())
|
||||
}
|
||||
if plugin.Client() != nil {
|
||||
t.Error("expected nil Client but found one")
|
||||
}
|
||||
if !plugin.IsV1() {
|
||||
t.Error("Expected true for V1 plugin")
|
||||
}
|
||||
})
|
||||
|
||||
// check negative case where plugin fruit doesn't implement banana
|
||||
_, err = Get("fruit", "banana")
|
||||
assert.Assert(t, errors.Is(err, ErrNotImplements))
|
||||
t.Run("not implemented", func(t *testing.T) {
|
||||
_, err := Get("fruit", "banana")
|
||||
assert.Assert(t, errors.Is(err, ErrNotImplements))
|
||||
})
|
||||
|
||||
// check negative case where plugin vegetable doesn't exist
|
||||
_, err = Get("vegetable", "potato")
|
||||
assert.Assert(t, errors.Is(err, ErrNotFound))
|
||||
t.Run("not exists", func(t *testing.T) {
|
||||
_, err := Get("vegetable", "potato")
|
||||
assert.Assert(t, errors.Is(err, ErrNotFound))
|
||||
})
|
||||
}
|
||||
|
||||
func TestPluginWithNoManifest(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue