Merge branch '15924-import-path'
[arvados.git] / sdk / go / arvados / resource_list_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package arvados
6
7 import (
8         "bytes"
9         "encoding/json"
10         "testing"
11         "time"
12 )
13
14 func TestMarshalFiltersWithNanoseconds(t *testing.T) {
15         t0 := time.Now()
16         t0str := t0.Format(time.RFC3339Nano)
17         buf, err := json.Marshal([]Filter{
18                 {Attr: "modified_at", Operator: "=", Operand: t0}})
19         if err != nil {
20                 t.Fatal(err)
21         }
22         if expect := []byte(`[["modified_at","=","` + t0str + `"]]`); 0 != bytes.Compare(buf, expect) {
23                 t.Errorf("Encoded as %q, expected %q", buf, expect)
24         }
25 }
26
27 func TestMarshalFiltersWithNil(t *testing.T) {
28         buf, err := json.Marshal([]Filter{
29                 {Attr: "modified_at", Operator: "=", Operand: nil}})
30         if err != nil {
31                 t.Fatal(err)
32         }
33         if expect := []byte(`[["modified_at","=",null]]`); 0 != bytes.Compare(buf, expect) {
34                 t.Errorf("Encoded as %q, expected %q", buf, expect)
35         }
36 }