mirror of https://github.com/docker/docs.git
				
				
				
			
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
| package commands
 | |
| 
 | |
| import (
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/docker/machine/commands/commandstest"
 | |
| 	"github.com/docker/machine/drivers/fakedriver"
 | |
| 	"github.com/docker/machine/libmachine/host"
 | |
| 	"github.com/docker/machine/libmachine/libmachinetest"
 | |
| 	"github.com/docker/machine/libmachine/state"
 | |
| 	"github.com/stretchr/testify/assert"
 | |
| )
 | |
| 
 | |
| func TestCmdIPMissingMachineName(t *testing.T) {
 | |
| 	commandLine := &commandstest.FakeCommandLine{}
 | |
| 	api := &libmachinetest.FakeAPI{}
 | |
| 
 | |
| 	err := cmdURL(commandLine, api)
 | |
| 
 | |
| 	assert.EqualError(t, err, "Error: Expected one machine name as an argument")
 | |
| }
 | |
| 
 | |
| func TestCmdIP(t *testing.T) {
 | |
| 	commandLine := &commandstest.FakeCommandLine{
 | |
| 		CliArgs: []string{"machine"},
 | |
| 	}
 | |
| 	api := &libmachinetest.FakeAPI{
 | |
| 		Hosts: []*host.Host{
 | |
| 			{
 | |
| 				Name: "machine",
 | |
| 				Driver: &fakedriver.Driver{
 | |
| 					MockState: state.Running,
 | |
| 					MockIP:    "1.2.3.4",
 | |
| 				},
 | |
| 			},
 | |
| 		},
 | |
| 	}
 | |
| 
 | |
| 	stdoutGetter := commandstest.NewStdoutGetter()
 | |
| 	defer stdoutGetter.Stop()
 | |
| 
 | |
| 	err := cmdIP(commandLine, api)
 | |
| 
 | |
| 	assert.NoError(t, err)
 | |
| 	assert.Equal(t, "1.2.3.4\n", stdoutGetter.Output())
 | |
| }
 |