Skip to content

Commit

Permalink
Simple ParseEnvFlags test.
Browse files Browse the repository at this point in the history
  • Loading branch information
aLekSer committed Apr 15, 2020
1 parent 02be64c commit fff3356
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
38 changes: 38 additions & 0 deletions cmd/sdk-server/main_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
2 changes: 1 addition & 1 deletion pkg/sdkserver/localsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdkserver/localsdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit fff3356

Please sign in to comment.