From fff33565d0b9d8e55f999696fbb29f399d2f9b45 Mon Sep 17 00:00:00 2001 From: Alexander Apalikov Date: Tue, 7 Apr 2020 18:43:07 +0300 Subject: [PATCH] Simple ParseEnvFlags test. --- cmd/sdk-server/main_test.go | 38 ++++++++++++++++++++++++++++++++++ pkg/sdkserver/localsdk.go | 2 +- pkg/sdkserver/localsdk_test.go | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 cmd/sdk-server/main_test.go diff --git a/cmd/sdk-server/main_test.go b/cmd/sdk-server/main_test.go new file mode 100644 index 0000000000..4a3d1418de --- /dev/null +++ b/cmd/sdk-server/main_test.go @@ -0,0 +1,38 @@ +// Copyright 2020 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "golang.org/x/net/context" + "google.golang.org/grpc" +) + +// TestRegisterTestSdkServer - test to verify +func TestRegisterTestSdkServer(t *testing.T) { + t.Parallel() + ctlConf := parseEnvFlags() + grpcServer := grpc.NewServer() + _, err := registerTestSdkServer(grpcServer, ctlConf) + assert.NoError(t, err) + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + ctx.Done() + ctlConf.LocalFile = "@@" + _, err = registerLocal(grpcServer, ctlConf) + assert.Error(t, err, "Wrong file name should produce an error") +} diff --git a/pkg/sdkserver/localsdk.go b/pkg/sdkserver/localsdk.go index 1ae55efde7..d872bc1ae6 100644 --- a/pkg/sdkserver/localsdk.go +++ b/pkg/sdkserver/localsdk.go @@ -170,7 +170,7 @@ func (l *LocalSDKServer) SetExpectedSequence(sequence []string) { // SetSdkName set SDK name to be added to the logs func (l *LocalSDKServer) SetSdkName(sdkName string) { l.testSdkName = sdkName - l.logger = l.logger.WithField("SDK Name", l.testSdkName) + l.logger = l.logger.WithField("sdkName", l.testSdkName) } // recordRequest append request name to slice diff --git a/pkg/sdkserver/localsdk_test.go b/pkg/sdkserver/localsdk_test.go index b2e69ad901..b802926b16 100644 --- a/pkg/sdkserver/localsdk_test.go +++ b/pkg/sdkserver/localsdk_test.go @@ -416,6 +416,6 @@ func TestSDKConformanceFunctionality(t *testing.T) { wg.Wait() l.SetExpectedSequence(expected) - b := EqualSets(l.expectedSequence, l.requestSequence) + b := l.EqualSets(l.expectedSequence, l.requestSequence) assert.True(t, b, "we should receive strings from all go routines %v %v", l.expectedSequence, l.requestSequence) }