github.com/zchee/zap-cloudlogging@v0.0.0-20220819025602-19b026d3900e/service_test.go (about) 1 // Copyright 2022 The zap-cloudlogging Authors 2 // SPDX-License-Identifier: BSD-3-Clause 3 4 package zapcloudlogging 5 6 import ( 7 "testing" 8 9 "github.com/google/go-cmp/cmp" 10 "github.com/google/go-cmp/cmp/cmpopts" 11 "go.uber.org/zap" 12 "go.uber.org/zap/zapcore" 13 ) 14 15 func TestServiceContext(t *testing.T) { 16 t.Parallel() 17 18 field := zapcore.Field{ 19 Key: "serviceContext", 20 Type: zapcore.ObjectMarshalerType, 21 } 22 23 if diff := cmp.Diff(field, ServiceContext("test service name"), 24 cmpopts.IgnoreFields(zap.Field{}, "Interface"), 25 ); diff != "" { 26 t.Fatalf("(-want, +got)\n%s\n", diff) 27 } 28 }