Skip to content
Snippets Groups Projects
Select Git revision
2 results Searching

bugs.c

Blame
  • config_loader_test.go 15.97 KiB
    /*
     * Licensed to the Apache Software Foundation (ASF) under one or more
     * contributor license agreements.  See the NOTICE file distributed with
     * this work for additional information regarding copyright ownership.
     * The ASF licenses this file to You 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 config
    
    import (
    	"path/filepath"
    	"sort"
    	"sync"
    	"testing"
    )
    
    import (
    	"github.com/Workiva/go-datastructures/slice/skip"
    	gxset "github.com/dubbogo/gost/container/set"
    	gxpage "github.com/dubbogo/gost/page"
    	"github.com/stretchr/testify/assert"
    	"go.uber.org/atomic"
    )
    
    import (
    	"github.com/apache/dubbo-go/cluster/cluster_impl"
    	"github.com/apache/dubbo-go/common"
    	"github.com/apache/dubbo-go/common/config"
    	"github.com/apache/dubbo-go/common/constant"
    	"github.com/apache/dubbo-go/common/extension"
    	"github.com/apache/dubbo-go/common/logger"
    	"github.com/apache/dubbo-go/common/proxy/proxy_factory"
    	"github.com/apache/dubbo-go/config_center"
    	"github.com/apache/dubbo-go/metadata/service"
    	"github.com/apache/dubbo-go/registry"
    )
    
    const mockConsumerConfigPath = "./testdata/consumer_config.yml"
    const mockProviderConfigPath = "./testdata/provider_config.yml"
    
    func TestConfigLoader(t *testing.T) {
    	conPath, err := filepath.Abs(mockConsumerConfigPath)
    	assert.NoError(t, err)
    	proPath, err := filepath.Abs(mockProviderConfigPath)
    	assert.NoError(t, err)
    
    	assert.Nil(t, consumerConfig)
    	assert.Equal(t, ConsumerConfig{}, GetConsumerConfig())
    	assert.Nil(t, providerConfig)
    	assert.Equal(t, ProviderConfig{}, GetProviderConfig())
    
    	err = ConsumerInit(conPath)
    	assert.NoError(t, err)
    	err = ProviderInit(proPath)
    	assert.NoError(t, err)
    
    	assert.NotNil(t, consumerConfig)
    	assert.NotEqual(t, ConsumerConfig{}, GetConsumerConfig())
    	assert.NotNil(t, providerConfig)
    	assert.NotEqual(t, ProviderConfig{}, GetProviderConfig())