dubbo.apache.org/dubbo-go/v3@v3.1.1/config/application_config_test.go (about)

     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one or more
     3   * contributor license agreements.  See the NOTICE file distributed with
     4   * this work for additional information regarding copyright ownership.
     5   * The ASF licenses this file to You under the Apache License, Version 2.0
     6   * (the "License"); you may not use this file except in compliance with
     7   * the License.  You may obtain a copy of the License at
     8   *
     9   *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  
    18  package config
    19  
    20  import (
    21  	"testing"
    22  )
    23  
    24  import (
    25  	"github.com/stretchr/testify/assert"
    26  )
    27  
    28  import (
    29  	"dubbo.apache.org/dubbo-go/v3/common/constant"
    30  )
    31  
    32  func TestApplicationConfig(t *testing.T) {
    33  
    34  	err := Load(WithPath("./testdata/config/application/application.yaml"))
    35  	assert.Nil(t, err)
    36  
    37  	center := rootConfig.Registries
    38  	assert.NotNil(t, center)
    39  }
    40  
    41  func TestApplicationConfigBuilder(t *testing.T) {
    42  
    43  	application := NewApplicationConfigBuilder().
    44  		SetOrganization("organization").
    45  		SetName("name").
    46  		SetModule("module").
    47  		SetVersion("version").
    48  		SetOwner("owner").
    49  		SetEnvironment("environment").
    50  		SetMetadataType("metadataType").
    51  		Build()
    52  
    53  	err := application.check()
    54  	assert.Nil(t, err)
    55  	err = application.Init()
    56  
    57  	assert.Nil(t, err)
    58  	assert.Equal(t, application.Name, "name")
    59  	assert.Equal(t, application.Organization, "organization")
    60  	assert.Equal(t, application.Module, "module")
    61  	assert.Equal(t, application.Version, "version")
    62  	assert.Equal(t, application.Owner, "owner")
    63  	assert.Equal(t, application.Environment, "environment")
    64  	assert.Equal(t, application.MetadataType, "metadataType")
    65  	assert.Equal(t, application.Prefix(), constant.ApplicationConfigPrefix)
    66  }