github.com/polarismesh/polaris@v1.17.8/service/default_test.go (about) 1 /** 2 * Tencent is pleased to support the open source community by making Polaris available. 3 * 4 * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 * 6 * Licensed under the BSD 3-Clause License (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * https://opensource.org/licenses/BSD-3-Clause 11 * 12 * Unless required by applicable law or agreed to in writing, software distributed 13 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 * specific language governing permissions and limitations under the License. 16 */ 17 18 package service 19 20 import ( 21 "context" 22 "sync" 23 "testing" 24 25 "github.com/golang/mock/gomock" 26 "github.com/stretchr/testify/assert" 27 28 "github.com/polarismesh/polaris/auth" 29 "github.com/polarismesh/polaris/store/mock" 30 ) 31 32 func Test_Initialize(t *testing.T) { 33 t.Cleanup(func() { 34 once = sync.Once{} 35 finishInit = false 36 }) 37 38 ctrl := gomock.NewController(t) 39 s := mock.NewMockStore(ctrl) 40 41 _, _, err := auth.TestInitialize(context.Background(), &auth.Config{ 42 Option: map[string]interface{}{}, 43 }, s, nil) 44 assert.NoError(t, err) 45 46 err = Initialize(context.Background(), &Config{}) 47 assert.NoError(t, err) 48 49 svr, err := GetOriginServer() 50 assert.NoError(t, err) 51 assert.NotNil(t, svr) 52 53 dSvr, err := GetServer() 54 assert.NoError(t, err) 55 assert.NotNil(t, dSvr) 56 }