mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 10:37:56 +00:00 
			
		
		
		
	 6ed8b88f5f
			
		
	
	6ed8b88f5f
	
	
	
		
			
			@mitchellh suggested we fork `cli` and switch to that. Since we primarily use the interfaces in `cli`, and the new fork has not changed those, this is (mostly) a drop-in replacement. A small fix will be necessary for Vault Enterprise, I believe.
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright (c) HashiCorp, Inc.
 | |
| // SPDX-License-Identifier: BUSL-1.1
 | |
| 
 | |
| package command
 | |
| 
 | |
| import (
 | |
| 	"strings"
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/hashicorp/cli"
 | |
| 	"github.com/hashicorp/vault/version"
 | |
| )
 | |
| 
 | |
| func testVersionCommand(tb testing.TB) (*cli.MockUi, *VersionCommand) {
 | |
| 	tb.Helper()
 | |
| 
 | |
| 	ui := cli.NewMockUi()
 | |
| 	return ui, &VersionCommand{
 | |
| 		VersionInfo: &version.VersionInfo{},
 | |
| 		BaseCommand: &BaseCommand{
 | |
| 			UI: ui,
 | |
| 		},
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func TestVersionCommand_Run(t *testing.T) {
 | |
| 	t.Parallel()
 | |
| 
 | |
| 	t.Run("output", func(t *testing.T) {
 | |
| 		t.Parallel()
 | |
| 
 | |
| 		client, closer := testVaultServer(t)
 | |
| 		defer closer()
 | |
| 
 | |
| 		ui, cmd := testVersionCommand(t)
 | |
| 		cmd.client = client
 | |
| 
 | |
| 		code := cmd.Run(nil)
 | |
| 		if exp := 0; code != exp {
 | |
| 			t.Errorf("expected %d to be %d", code, exp)
 | |
| 		}
 | |
| 
 | |
| 		expected := "Vault"
 | |
| 		combined := ui.OutputWriter.String() + ui.ErrorWriter.String()
 | |
| 		if !strings.Contains(combined, expected) {
 | |
| 			t.Errorf("expected %q to equal %q", combined, expected)
 | |
| 		}
 | |
| 	})
 | |
| 
 | |
| 	t.Run("no_tabs", func(t *testing.T) {
 | |
| 		t.Parallel()
 | |
| 
 | |
| 		_, cmd := testVersionCommand(t)
 | |
| 		assertNoTabs(t, cmd)
 | |
| 	})
 | |
| }
 |