github.com/polarismesh/polaris@v1.17.8/test/integrate/config_file_group_test.go (about)

     1  //go:build integration
     2  // +build integration
     3  
     4  /**
     5   * Tencent is pleased to support the open source community by making Polaris available.
     6   *
     7   * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
     8   *
     9   * Licensed under the BSD 3-Clause License (the "License");
    10   * you may not use this file except in compliance with the License.
    11   * You may obtain a copy of the License at
    12   *
    13   * https://opensource.org/licenses/BSD-3-Clause
    14   *
    15   * Unless required by applicable law or agreed to in writing, software distributed
    16   * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    17   * CONDITIONS OF ANY KIND, either express or implied. See the License for the
    18   * specific language governing permissions and limitations under the License.
    19   */
    20  
    21  package test
    22  
    23  import (
    24  	"testing"
    25  
    26  	"github.com/stretchr/testify/assert"
    27  
    28  	api "github.com/polarismesh/polaris/common/api/v1"
    29  	"github.com/polarismesh/polaris/common/utils"
    30  	"github.com/polarismesh/polaris/test/integrate/http"
    31  	"github.com/polarismesh/polaris/test/integrate/resource"
    32  )
    33  
    34  func TestConfigCenter_ConfigFileGroup(t *testing.T) {
    35  
    36  	client := http.NewClient(httpserverAddress, httpserverVersion)
    37  
    38  	ns := resource.CreateNamespaces()
    39  	groups := resource.MockConfigGroups(ns[0])
    40  
    41  	defer func() {
    42  		for i := range groups {
    43  			if _, err := client.DeleteConfigGroup(groups[i]); err != nil {
    44  				t.Fatal(err)
    45  			}
    46  		}
    47  		client.DeleteNamespaces(ns)
    48  	}()
    49  
    50  	t.Run("配置中心-创建配置分组", func(t *testing.T) {
    51  
    52  		for i := range groups {
    53  
    54  			resp, err := client.CreateConfigGroup(groups[i])
    55  
    56  			if err != nil {
    57  				t.Fatal(err)
    58  			}
    59  
    60  			assert.Equal(t, resp.GetCode().GetValue(), api.ExecuteSuccess, resp.GetInfo().GetValue())
    61  		}
    62  	})
    63  
    64  	t.Run("配置中心-更新配置分组", func(t *testing.T) {
    65  
    66  		group := groups[0]
    67  
    68  		newComment := utils.NewStringValue("update config_file_group " + utils.NewUUID())
    69  		group.Comment = newComment
    70  
    71  		resp, err := client.UpdateConfigGroup(group)
    72  
    73  		if err != nil {
    74  			t.Fatal(err)
    75  		}
    76  		assert.Equal(t, resp.GetCode().GetValue(), api.ExecuteSuccess, resp.GetInfo().GetValue())
    77  
    78  		queryResp, err := client.QueryConfigGroup(group, 0, 100)
    79  		if err != nil {
    80  			t.Fatal(err)
    81  		}
    82  		assert.Equal(t, resp.GetCode().GetValue(), api.ExecuteSuccess, resp.GetInfo().GetValue())
    83  		assert.Equal(t, 1, len(queryResp.ConfigFileGroups), resp.GetInfo().GetValue())
    84  
    85  		queryGroup := queryResp.ConfigFileGroups[0]
    86  		assert.NotNil(t, queryGroup, "query group nil")
    87  		assert.Equal(t, group.Comment, queryGroup.Comment, "group comment is not equal")
    88  
    89  	})
    90  
    91  	t.Run("配置中心-删除配置分组", func(t *testing.T) {
    92  	})
    93  }