github.com/hxx258456/fabric-ca-gm@v0.0.3-0.20221111064038-a268ad7e3a37/lib/serverinfo_test.go (about)

     1  /*
     2  Copyright IBM Corp. 2017, 2018 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8                   http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  package lib
    17  
    18  import (
    19  	"os"
    20  	"testing"
    21  
    22  	"github.com/hxx258456/fabric-ca-gm/internal/pkg/api"
    23  	"github.com/hxx258456/fabric-ca-gm/internal/pkg/util"
    24  	"github.com/hxx258456/fabric-ca-gm/lib/metadata"
    25  	"github.com/stretchr/testify/assert"
    26  )
    27  
    28  func TestGetServerVersion(t *testing.T) {
    29  	os.RemoveAll(rootDir)
    30  	defer os.RemoveAll(rootDir)
    31  
    32  	var err error
    33  
    34  	metadata.Version = "1.1.0"
    35  	srv := TestGetRootServer(t)
    36  	err = srv.Start()
    37  	util.FatalError(t, err, "Failed to start server")
    38  	defer srv.Stop()
    39  
    40  	client := getTestClient(7075)
    41  	resp, err := client.GetCAInfo(&api.GetCAInfoRequest{
    42  		CAName: "",
    43  	})
    44  	assert.NoError(t, err, "Failed to get back server info")
    45  
    46  	assert.Equal(t, "1.1.0", resp.Version)
    47  }