Ejemplo n.º 1
0
func testSyncWithMount(mountID ID, wd, remotePath string) (s *Sync, m Mount, err error) {
	opts := SyncOpts{
		ClientFunc: func(ID) (client.Client, error) {
			return testutil.NewClient(), nil
		},
		WorkDir: wd,
	}

	s, err = NewSync(opts)
	if err != nil {
		return nil, Mount{}, err
	}

	// Add new mount.
	m = Mount{
		Path:       "some/path",
		RemotePath: remotePath,
	}

	return s, m, s.Add(mountID, m)
}
Ejemplo n.º 2
0
func TestCreateBalance(t *testing.T) {
	var (
		client  = testutil.NewClient()
		builder = testutil.NewBuilder(client)
		id      = machine.ID("serv")
	)

	g, err := New(testOptions(builder))
	if err != nil {
		t.Fatalf("want err = nil; got %v", err)
	}
	defer g.Close()

	req := &CreateRequest{
		Addresses: map[machine.ID][]machine.Addr{
			id: {testutil.TurnOffAddr()},
		},
	}

	if _, err := g.Create(req); err != nil {
		t.Fatalf("want err = nil; got %v", err)
	}

	if err := builder.WaitForBuild(time.Second); err != nil {
		t.Fatalf("want err = nil; got %v", err)
	}

	// Create with empty addresses should remove previously added machine.
	if _, err := g.Create(&CreateRequest{}); err != nil {
		t.Fatalf("want err = nil; got %v", err)
	}

	// Client context should be closed.
	if err := testutil.WaitForContextClose(client.Context(), time.Second); err != nil {
		t.Fatalf("want err = nil; got %v", err)
	}
}