trpc.group/trpc-go/trpc-cmdline@v1.0.9/cmd/version/version_test.go (about)

     1  // Tencent is pleased to support the open source community by making tRPC available.
     2  //
     3  // Copyright (C) 2023 THL A29 Limited, a Tencent company.
     4  // All rights reserved.
     5  //
     6  // If you have downloaded a copy of the tRPC source code from Tencent,
     7  // please note that tRPC source code is licensed under the  Apache 2.0 License,
     8  // A copy of the Apache 2.0 License is included in this file.
     9  
    10  package version
    11  
    12  import (
    13  	"strings"
    14  	"testing"
    15  
    16  	"trpc.group/trpc-go/trpc-cmdline/cmd/internal"
    17  	"trpc.group/trpc-go/trpc-cmdline/config"
    18  )
    19  
    20  func TestCmd_Version(t *testing.T) {
    21  	if _, err := config.Init(); err != nil {
    22  		t.Errorf("config init error: %v", err)
    23  	}
    24  
    25  	versionCmd := CMD()
    26  	output, err := internal.RunAndWatch(versionCmd, nil, nil)
    27  	if err != nil {
    28  		t.Errorf("versionCmd run and watch error: %v", err)
    29  	}
    30  
    31  	if !strings.Contains(output, config.TRPCCliVersion) {
    32  		t.Errorf("versionCmd.Run() output version mismatch")
    33  	}
    34  }