Skip to content

Commit 70b71dc

Browse files
soapy1phinze
authored andcommitted
Make no-op test work
1 parent 8ca1a29 commit 70b71dc

File tree

7 files changed

+72
-306
lines changed

7 files changed

+72
-306
lines changed

cmd/vagrant-entrypoint/main.go

Lines changed: 0 additions & 74 deletions
This file was deleted.

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69/go.
257257
github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
258258
github.com/containerd/containerd v1.3.3 h1:LoIzb5y9x5l8VKAlyrbusNPXqBY0+kviRloxFUMFwKc=
259259
github.com/containerd/containerd v1.3.3/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
260+
github.com/containerd/containerd v1.4.3 h1:ijQT13JedHSHrQGWFcGEwzcNKrAGIiZ+jSD5QQG07SY=
260261
github.com/containerd/containerd v1.4.3/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
261262
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
262263
github.com/containerd/continuity v0.0.0-20200107194136-26c1120b8d41 h1:kIFnQBO7rQ0XkMe6xEwbybYHBEaWmh/f++laI6Emt7M=
@@ -541,6 +542,7 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV
541542
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
542543
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
543544
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
545+
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
544546
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
545547
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
546548
github.com/golang-migrate/migrate/v4 v4.10.0 h1:76R6UL3BGnDTpYeittMtfpaNvGBH5zMZatO/fCzIjWo=

internal/client/noop_test.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66

77
"github.com/hashicorp/go-hclog"
88
"github.com/stretchr/testify/require"
9-
10-
"github.com/hashicorp/vagrant/internal/server/singleprocess"
119
)
1210

1311
func init() {
@@ -17,15 +15,10 @@ func init() {
1715
func TestProjectNoop(t *testing.T) {
1816
ctx := context.Background()
1917
require := require.New(t)
20-
client := singleprocess.TestServer(t)
2118

2219
// Build our client
23-
c := TestProject(t, WithClient(client), WithLocal())
24-
app := c.App(TestApp(t, c))
25-
26-
// TODO(mitchellh): once we have an API to list jobs, verify we have
27-
// no jobs, and then verify we execute a job after.
20+
tp := TestBasis(t)
2821

2922
// Noop
30-
require.NoError(app.Noop(ctx))
23+
require.NoError(tp.Noop(ctx))
3124
}

internal/client/testing.go

Lines changed: 57 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,59 @@
11
package client
22

3-
// import (
4-
// "context"
5-
// "io/ioutil"
6-
// "os"
7-
8-
// "github.com/mitchellh/go-testing-interface"
9-
// "github.com/stretchr/testify/require"
10-
11-
// configpkg "github.com/hashicorp/vagrant/internal/config"
12-
// pb "github.com/hashicorp/vagrant/internal/server/gen"
13-
// "github.com/hashicorp/vagrant/internal/server/singleprocess"
14-
// )
15-
16-
// // TestProject returns an initialized client pointing to an in-memory test
17-
// // server. This will close automatically on test completion.
18-
// //
19-
// // This will also change the working directory to a temporary directory
20-
// // so that any side effect file creation doesn't impact the real working
21-
// // directory. If you need to use your working directory, query it before
22-
// // calling this.
23-
// func TestProject(t testing.T, opts ...Option) *Project {
24-
// require := require.New(t)
25-
// client := singleprocess.TestServer(t)
26-
27-
// ctx := context.Background()
28-
29-
// basis, err := NewBasis(ctx, WithClient(client), WithLocal())
30-
// require.NoError(err)
31-
32-
// // Initialize our client
33-
// result, err := New(ctx, append([]Option{
34-
// WithBasis(basis),
35-
// WithProjectRef(&pb.Ref_Project{Project: "test_p"}),
36-
// }, opts...)...)
37-
// require.NoError(err)
38-
39-
// // Move into a temporary directory
40-
// td := testTempDir(t)
41-
// testChdir(t, td)
42-
43-
// // Create a valid vagrant configuration file
44-
// configpkg.TestConfigFile(t, configpkg.TestSource(t))
45-
46-
// return result
47-
// }
48-
49-
// // TestApp returns an app reference that can be used for testing.
50-
// func TestApp(t testing.T, c *Project) string {
51-
// // Initialize our app
52-
// singleprocess.TestApp(t, c.Client(), c.App("test_a").Ref())
53-
54-
// return "test_a"
55-
// }
56-
57-
// func testChdir(t testing.T, dir string) {
58-
// pwd, err := os.Getwd()
59-
// require.NoError(t, err)
60-
// require.NoError(t, os.Chdir(dir))
61-
// t.Cleanup(func() { require.NoError(t, os.Chdir(pwd)) })
62-
// }
63-
64-
// func testTempDir(t testing.T) string {
65-
// dir, err := ioutil.TempDir("", "vagrant-test")
66-
// require.NoError(t, err)
67-
// t.Cleanup(func() { os.RemoveAll(dir) })
68-
// return dir
69-
// }
3+
import (
4+
"context"
5+
"io/ioutil"
6+
"os"
7+
8+
"github.com/mitchellh/go-testing-interface"
9+
"github.com/stretchr/testify/require"
10+
11+
"github.com/hashicorp/vagrant/internal/server/singleprocess"
12+
)
13+
14+
// TestBasis returns an initialized client pointing to an in-memory test
15+
// server. This will close automatically on test completion.
16+
//
17+
// This will also change the working directory to a temporary directory
18+
// so that any side effect file creation doesn't impact the real working
19+
// directory. If you need to use your working directory, query it before
20+
// calling this.
21+
func TestBasis(t testing.T, opts ...Option) *Basis {
22+
require := require.New(t)
23+
client := singleprocess.TestServer(t)
24+
25+
ctx := context.Background()
26+
27+
basis, err := New(ctx, WithClient(client), WithLocal())
28+
require.NoError(err)
29+
30+
// // Initialize our client
31+
// result, err := New(ctx, append([]Option{
32+
// WithBasis(basis),
33+
// WithProjectRef(&pb.Ref_Project{Project: "test_p"}),
34+
// }, opts...)...)
35+
// require.NoError(err)
36+
37+
// Move into a temporary directory
38+
td := testTempDir(t)
39+
testChdir(t, td)
40+
41+
// Create a valid vagrant configuration file
42+
// configpkg.TestConfigFile(t, configpkg.TestSource(t))
43+
44+
return basis
45+
}
46+
47+
func testChdir(t testing.T, dir string) {
48+
pwd, err := os.Getwd()
49+
require.NoError(t, err)
50+
require.NoError(t, os.Chdir(dir))
51+
t.Cleanup(func() { require.NoError(t, os.Chdir(pwd)) })
52+
}
53+
54+
func testTempDir(t testing.T) string {
55+
dir, err := ioutil.TempDir("", "vagrant-test")
56+
require.NoError(t, err)
57+
t.Cleanup(func() { os.RemoveAll(dir) })
58+
return dir
59+
}

internal/config/plugin_test.go

Lines changed: 0 additions & 128 deletions
This file was deleted.

internal/core/target_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,3 @@ func TestTargetSpecializeBad(t *testing.T) {
3131
t.Errorf("Should not specialize to an unsupported type")
3232
}
3333
}
34-
35-
func TestRun(t *testing.T) {
36-
// TODO: needs
37-
// - to be able to create a Task
38-
// tt, _ := TestTarget(t)
39-
// ctx := context.Background()
40-
// tk := &vagrant_server.Task{}
41-
42-
// err := tt.Run(ctx, tk)
43-
// if err != nil {
44-
// t.Errorf("Run returned an error")
45-
// }
46-
}

0 commit comments

Comments
 (0)