handle watch errors everywhere

This commit is contained in:
Daniel Smith
2014-09-22 17:37:12 -07:00
parent 8fd1fb4337
commit f211e46f20
6 changed files with 47 additions and 14 deletions

View File

@@ -23,6 +23,7 @@ import (
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
)
func TestErrorNew(t *testing.T) {
@@ -131,3 +132,23 @@ func Test_reasonForError(t *testing.T) {
t.Errorf("unexpected reason type: %#v", a)
}
}
type TestType struct{}
func (*TestType) IsAnAPIObject() {}
func TestFromObject(t *testing.T) {
table := []struct {
obj runtime.Object
message string
}{
{&api.Status{Message: "foobar"}, "foobar"},
{&TestType{}, "unexpected object: &{}"},
}
for _, item := range table {
if e, a := item.message, FromObject(item.obj).Error(); e != a {
t.Errorf("Expected %v, got %v", e, a)
}
}
}