mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 02:28:09 +00:00 
			
		
		
		
	 35df9489c7
			
		
	
	35df9489c7
	
	
	
		
			
			Move version out of SDK. For now it's a copy rather than move: the part not addressed by this change is sdk/helper/useragent.String, which we'll want to remove in favour of PluginString. That will have to wait until we've removed uses of useragent.String from all builtins.
		
			
				
	
	
		
			54 lines
		
	
	
		
			996 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			996 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package command
 | |
| 
 | |
| import (
 | |
| 	"strings"
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/hashicorp/vault/version"
 | |
| 	"github.com/mitchellh/cli"
 | |
| )
 | |
| 
 | |
| 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)
 | |
| 	})
 | |
| }
 |