trpc.group/trpc-go/trpc-cmdline@v1.0.9/cmd/completion/completion_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 completion 11 12 import ( 13 "testing" 14 15 "github.com/stretchr/testify/require" 16 17 "trpc.group/trpc-go/trpc-cmdline/cmd/internal" 18 ) 19 20 func TestCmd_Completion(t *testing.T) { 21 completionCmd := CMD() 22 // bash 23 output, err := internal.RunAndWatch(completionCmd, nil, []string{"bash"}) 24 require.Nil(t, err) 25 require.NotEmpty(t, output) 26 // t.Logf("generated bash completion script: \n%s", output) 27 28 // zsh 29 output, err = internal.RunAndWatch(completionCmd, nil, []string{"zsh"}) 30 require.Nil(t, err) 31 require.NotEmpty(t, output) 32 // t.Logf("generated zsh completion script: \n%s", output) 33 34 // fish 35 output, err = internal.RunAndWatch(completionCmd, nil, []string{"fish"}) 36 require.Nil(t, err) 37 require.NotEmpty(t, output) 38 // t.Logf("generated fish completion script: \n%s", output) 39 40 // powershell 41 output, err = internal.RunAndWatch(completionCmd, nil, []string{"powershell"}) 42 require.Nil(t, err) 43 require.NotEmpty(t, output) 44 // t.Logf("generated powershell completion script: \n%s", output) 45 }