Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
ref(pkg/driver): update Lookup method to return error if not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
vdice committed Apr 25, 2019
1 parent f368562 commit 39c2595
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ func Lookup(name string) (Driver, error) {
return &DockerDriver{}, nil
case "debug":
return &DebugDriver{}, nil
default:
case "command":
return &CommandDriver{Name: name}, nil
default:
return nil, fmt.Errorf("unsupported driver: %s", name)
}
}

Expand Down
9 changes: 8 additions & 1 deletion pkg/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ import (
var _ Driver = &DockerDriver{}
var _ Driver = &DebugDriver{}

func TestLookup_ExternalDriver(t *testing.T) {
func TestLookup_UnsupportedDriver(t *testing.T) {
d, err := Lookup("no_such_driver")

assert.Nil(t, d)
assert.Error(t, err)
}

func TestLookup_CommandDriver(t *testing.T) {
d, err := Lookup("command")

assert.NoError(t, err)
assert.IsType(t, d, &CommandDriver{})
}
Expand Down

0 comments on commit 39c2595

Please sign in to comment.