}
}
} else {
- return []interface{}{}, errors.New("Key/value pairs doesn't match")
+ if reflectType.Elem().Kind() == reflect.Uint8 {
+ retVal = append(retVal, v)
+ shouldBeKey = true
+ } else {
+ return []interface{}{}, errors.New("Key/value pairs doesn't match")
+ }
}
case reflect.Array:
if shouldBeKey {
}
}
} else {
- return []interface{}{}, errors.New("Key/value pairs doesn't match")
+ if reflectType.Elem().Kind() == reflect.Uint8 {
+ retVal = append(retVal, v)
+ shouldBeKey = true
+ } else {
+ return []interface{}{}, errors.New("Key/value pairs doesn't match")
+ }
}
default:
if shouldBeKey {
return err
}
+//RemoveAllAndPublish removes all keys under the namespace and if successfull, it
+//will publish an event to given channel. This operation is not atomic, thus it is
+//not guaranteed that all keys are removed.
func (s *SdlInstance) RemoveAllAndPublish(channelsAndEvents []string) error {
keys, err := s.Keys(s.nsPrefix + "*")
if err != nil {
m.AssertExpectations(t)
}
+func TestWriteByteSliceAsValue(t *testing.T) {
+ m, i := setup()
+
+ msetExpected := []interface{}{"{namespace},key1", []byte{1, 2, 3, 4, 5}}
+
+ m.On("MSet", msetExpected).Return(nil)
+ err := i.Set("key1", []byte{1, 2, 3, 4, 5})
+ assert.Nil(t, err)
+ m.AssertExpectations(t)
+}
+
+func TestWriteByteSliceAsValueMixed(t *testing.T) {
+ m, i := setup()
+
+ msetExpected := []interface{}{"{namespace},key1", []byte{1, 2, 3, 4, 5}, "{namespace},key2", "value2"}
+
+ m.On("MSet", msetExpected).Return(nil)
+ err := i.Set("key1", []byte{1, 2, 3, 4, 5}, []string{"key2", "value2"})
+ assert.Nil(t, err)
+ m.AssertExpectations(t)
+}
+
+func TestWriteByteArrayAsValue(t *testing.T) {
+ m, i := setup()
+
+ msetExpected := []interface{}{"{namespace},key1", [5]byte{1, 2, 3, 4, 5}}
+
+ m.On("MSet", msetExpected).Return(nil)
+ err := i.Set("key1", [5]byte{1, 2, 3, 4, 5})
+ assert.Nil(t, err)
+ m.AssertExpectations(t)
+}
+
func TestWriteMixed(t *testing.T) {
m, i := setup()