Exemple #1
0
func TestDomainsGet_DomainRequred(t *testing.T) {
	client := &godo.Client{}

	withTestClient(client, func(c *TestConfig) {
		ns := "test"
		err := RunDomainGet(ns, c, ioutil.Discard, []string{})
		assert.Error(t, err)
	})
}
Exemple #2
0
func TestRecordCreate_RequiredArguments(t *testing.T) {
	client := &godo.Client{}

	withTestClient(client, func(c *TestConfig) {
		ns := "test"
		err := RunRecordCreate(ns, c, ioutil.Discard, []string{})
		assert.Error(t, err)
	})
}
Exemple #3
0
func TestMockCommand_Start(t *testing.T) {
	mc := NewMockCommand("/bin/ls")

	startErr := errors.New("start error")
	stopErr := errors.New("top error")
	mc.startFn = func() error {
		return startErr
	}
	mc.stopFn = func() error {
		return stopErr
	}

	err := mc.Start()
	assert.Error(t, err)
	assert.True(t, mc.running)

	err = mc.Stop()
	assert.Error(t, err)
	assert.False(t, mc.running)

}
Exemple #4
0
func TestMockCommmand_Run(t *testing.T) {
	mc := NewMockCommand("/bin/ls")
	assert.Equal(t, "/bin/ls", mc.path)

	runErr := errors.New("an error")
	mc.runFn = func() error {
		return runErr
	}

	_, err := mc.Run()
	assert.Error(t, err)
}
Exemple #5
0
func TestSSH_InvalidID(t *testing.T) {
	didFetchDroplet := false

	client := &godo.Client{
		Droplets: &doit.DropletsServiceMock{
			GetFn: func(id int) (*godo.Droplet, *godo.Response, error) {
				didFetchDroplet = true
				return nil, nil, fmt.Errorf("not here")
			},
		},
	}

	withTestClient(client, func(c *TestConfig) {
		ms := &sshMock{}
		c.SSHFn = ms.cmd()

		ns := "test"
		c.Set(ns, doit.ArgDropletID, testDroplet.ID)

		err := RunSSH(ns, c, ioutil.Discard, []string{})
		assert.Error(t, err)
	})
}