github.com/polarismesh/polaris@v1.17.8/config/utils_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 config
    19  
    20  import (
    21  	"testing"
    22  
    23  	"github.com/golang/protobuf/ptypes/wrappers"
    24  	"github.com/stretchr/testify/assert"
    25  )
    26  
    27  func TestCalMd5(t *testing.T) {
    28  	assert.Equal(t, "d41d8cd98f00b204e9800998ecf8427e", CalMd5(""))
    29  	assert.Equal(t, "acbd18db4cc2f85cedef654fccc4a4d8", CalMd5("foo"))
    30  
    31  	str := "38c5ee9532f037a20b93d0f804cf111fca4003e451d09a692d9dea8032308d9c64eda9047fcd5e850284a49b1a0cfb2ecd45"
    32  	assert.Equal(t, "02f463eb799797e2a978fb1a2ae2991e", CalMd5(str))
    33  }
    34  
    35  func TestCheckResourceName(t *testing.T) {
    36  	w := &wrappers.StringValue{Value: "123abc"}
    37  	err := CheckResourceName(w)
    38  	assert.Equal(t, err, nil)
    39  }
    40  
    41  func TestCheckFileName(t *testing.T) {
    42  	w := &wrappers.StringValue{Value: "123abc.test.log"}
    43  	err := CheckFileName(w)
    44  	assert.Equal(t, err, nil)
    45  }