From 3ecfced5752fa7a4da4aae7fdb8ea4f458d2741e Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Thu, 30 Jun 2016 18:53:11 -0400 Subject: [PATCH] field: test CanSet failure --- field_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/field_test.go b/field_test.go index b77e951..de9dc3b 100644 --- a/field_test.go +++ b/field_test.go @@ -133,6 +133,20 @@ func TestField_Set(t *testing.T) { } } +func TestField_NotSettable(t *testing.T) { + a := map[int]Baz{ + 4: Baz{ + A: "value", + }, + } + + s := New(a[4]) + + if err := s.Field("A").Set("newValue"); err != errNotSettable { + t.Errorf("Trying to set non-settable field should error with %q. Got %q instead.", errNotSettable, err) + } +} + func TestField_Zero(t *testing.T) { s := newStruct()