add _additional creationTimeUnix, lastUpdateTimeUnix tests
package get
import (
+ "fmt"
"testing"
+ "time"
"github.com/go-openapi/strfmt"
"github.com/graphql-go/graphql/language/ast"
@@ -292,6 +294,9 @@ func TestExtractAdditionalFields(t *testing.T) {
expectedResult interface{}
}
+ // To facilitate testing timestamps
+ nowString := fmt.Sprint(time.Now().UnixNano() / int64(time.Millisecond))
+
tests := []test{
test{
name: "with _additional certainty",
@@ -337,6 +342,50 @@ func TestExtractAdditionalFields(t *testing.T) {
},
},
},
+ test{
+ name: "with _additional creationTimeUnix",
+ query: "{ Get { SomeAction { _additional { creationTimeUnix } } } }",
+ expectedParams: traverser.GetParams{
+ ClassName: "SomeAction",
+ AdditionalProperties: additional.Properties{
+ CreationTimeUnix: true,
+ },
+ },
+ resolverReturn: []interface{}{
+ map[string]interface{}{
+ "_additional": map[string]interface{}{
+ "creationTimeUnix": nowString,
+ },
+ },
+ },
+ expectedResult: map[string]interface{}{
+ "_additional": map[string]interface{}{
+ "creationTimeUnix": nowString,
+ },
+ },
+ },
+ test{
+ name: "with _additional lastUpdateTimeUnix",
+ query: "{ Get { SomeAction { _additional { lastUpdateTimeUnix } } } }",
+ expectedParams: traverser.GetParams{
+ ClassName: "SomeAction",
+ AdditionalProperties: additional.Properties{
+ LastUpdateTimeUnix: true,
+ },
+ },
+ resolverReturn: []interface{}{
+ map[string]interface{}{
+ "_additional": map[string]interface{}{
+ "lastUpdateTimeUnix": nowString,
+ },
+ },
+ },
+ expectedResult: map[string]interface{}{
+ "_additional": map[string]interface{}{
+ "lastUpdateTimeUnix": nowString,
+ },
+ },
+ },
test{
name: "with _additional classification",
query: "{ Get { SomeAction { _additional { classification { id completed classifiedFields scope basedOn } } } } }",
