logical/framework: add a field data type for parsing integer arrays (#4064)

* logical/framework: add a field data type for parsing integer arrays

* Fix comment

* Add zero value
This commit is contained in:
Brian Kassouf
2018-03-02 15:01:13 -08:00
committed by GitHub
parent 4c66587fc8
commit 83a7d20b81
4 changed files with 113 additions and 5 deletions

View File

@@ -257,6 +257,93 @@ func TestFieldDataGet(t *testing.T) {
[]string{},
},
"comma int slice type, comma int with one value": {
map[string]*FieldSchema{
"foo": &FieldSchema{Type: TypeCommaIntSlice},
},
map[string]interface{}{
"foo": 1,
},
"foo",
[]int{1},
},
"comma int slice type, comma int with multi value slice": {
map[string]*FieldSchema{
"foo": &FieldSchema{Type: TypeCommaIntSlice},
},
map[string]interface{}{
"foo": []int{1, 2, 3},
},
"foo",
[]int{1, 2, 3},
},
"comma int slice type, comma int with multi value": {
map[string]*FieldSchema{
"foo": &FieldSchema{Type: TypeCommaIntSlice},
},
map[string]interface{}{
"foo": "1,2,3",
},
"foo",
[]int{1, 2, 3},
},
"comma int slice type, nil int slice value": {
map[string]*FieldSchema{
"foo": &FieldSchema{Type: TypeCommaIntSlice},
},
map[string]interface{}{
"foo": "",
},
"foo",
[]int{},
},
"commma int slice type, int slice with one value": {
map[string]*FieldSchema{
"foo": &FieldSchema{Type: TypeCommaIntSlice},
},
map[string]interface{}{
"foo": []interface{}{"1"},
},
"foo",
[]int{1},
},
"comma int slice type, int slice with multi value strings": {
map[string]*FieldSchema{
"foo": &FieldSchema{Type: TypeCommaIntSlice},
},
map[string]interface{}{
"foo": []interface{}{"1", "2", "3"},
},
"foo",
[]int{1, 2, 3},
},
"comma int slice type, int slice with multi value": {
map[string]*FieldSchema{
"foo": &FieldSchema{Type: TypeCommaIntSlice},
},
map[string]interface{}{
"foo": []interface{}{1, 2, 3},
},
"foo",
[]int{1, 2, 3},
},
"comma int slice type, empty int slice value": {
map[string]*FieldSchema{
"foo": &FieldSchema{Type: TypeCommaIntSlice},
},
map[string]interface{}{
"foo": []interface{}{},
},
"foo",
[]int{},
},
"name string type, valid string": {
map[string]*FieldSchema{
"foo": &FieldSchema{Type: TypeNameString},