github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/daemon/cluster/convert/network_test.go (about) 1 package convert // import "github.com/demonoid81/moby/daemon/cluster/convert" 2 3 import ( 4 "testing" 5 "time" 6 7 swarmapi "github.com/docker/swarmkit/api" 8 gogotypes "github.com/gogo/protobuf/types" 9 ) 10 11 func TestNetworkConvertBasicNetworkFromGRPCCreatedAt(t *testing.T) { 12 expected, err := time.Parse("Jan 2, 2006 at 3:04pm (MST)", "Jan 10, 2018 at 7:54pm (PST)") 13 if err != nil { 14 t.Fatal(err) 15 } 16 createdAt, err := gogotypes.TimestampProto(expected) 17 if err != nil { 18 t.Fatal(err) 19 } 20 21 nw := swarmapi.Network{ 22 Meta: swarmapi.Meta{ 23 Version: swarmapi.Version{ 24 Index: 1, 25 }, 26 CreatedAt: createdAt, 27 }, 28 } 29 30 n := BasicNetworkFromGRPC(nw) 31 if !n.Created.Equal(expected) { 32 t.Fatalf("expected time %s; received %s", expected, n.Created) 33 } 34 }