|
| 1 | +// |
| 2 | +// DISCLAIMER |
| 3 | +// |
| 4 | +// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany |
| 5 | +// |
| 6 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +// you may not use this file except in compliance with the License. |
| 8 | +// You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software |
| 13 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// See the License for the specific language governing permissions and |
| 16 | +// limitations under the License. |
| 17 | +// |
| 18 | +// Copyright holder is ArangoDB GmbH, Cologne, Germany |
| 19 | +// |
| 20 | + |
| 21 | +package v1 |
| 22 | + |
| 23 | +import ( |
| 24 | + "encoding/json" |
| 25 | + "reflect" |
| 26 | + "testing" |
| 27 | + |
| 28 | + "github.com/stretchr/testify/require" |
| 29 | +) |
| 30 | + |
| 31 | +func Test_ArangoTask_Details(t *testing.T) { |
| 32 | + arangoTaskDetails(t, int(5)) |
| 33 | + arangoTaskDetails(t, "test") |
| 34 | + arangoTaskDetails(t, []interface{}{"data", "two"}) |
| 35 | + arangoTaskDetails(t, map[string]interface{}{ |
| 36 | + "data": "exp", |
| 37 | + }) |
| 38 | +} |
| 39 | + |
| 40 | +func arangoTaskDetails(t *testing.T, obj interface{}) { |
| 41 | + arangoTaskDetailsExp(t, obj, obj) |
| 42 | +} |
| 43 | + |
| 44 | +func arangoTaskDetailsExp(t *testing.T, obj, exp interface{}) { |
| 45 | + t.Run(reflect.TypeOf(obj).String(), func(t *testing.T) { |
| 46 | + var d ArangoTaskDetails |
| 47 | + |
| 48 | + require.NoError(t, d.Set(obj)) |
| 49 | + |
| 50 | + b, err := json.Marshal(d) |
| 51 | + require.NoError(t, err) |
| 52 | + |
| 53 | + var n ArangoTaskDetails |
| 54 | + require.NoError(t, json.Unmarshal(b, &n)) |
| 55 | + |
| 56 | + require.NoError(t, n.Get(&exp)) |
| 57 | + |
| 58 | + require.EqualValues(t, obj, exp) |
| 59 | + }) |
| 60 | +} |
0 commit comments