-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cannot yet mock higher-level wrappers, like `*AndWait` because of generics are not yet supported by gomock (even in v1.7.0-rc.1)
- Loading branch information
Showing
5 changed files
with
1,009 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package sample | ||
|
||
import ( | ||
"context" | ||
"sample/mocks" | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
_ "github.com/golang/mock/mockgen/model" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/databricks/databricks-sdk-go/service/dbfs" | ||
"github.com/databricks/databricks-sdk-go/workspaces" | ||
) | ||
|
||
//go:generate mockgen -package=mocks -destination=mocks/dbfs.go github.com/databricks/databricks-sdk-go/service/dbfs DbfsService | ||
|
||
func TestClusters(t *testing.T) { | ||
ctrl := gomock.NewController(t) | ||
defer ctrl.Finish() | ||
|
||
m := mocks.New MockDbfsService(ctrl) | ||
|
||
ctx := context.Background() | ||
m.EXPECT(). | ||
Create(gomock.Any(), gomock.Any()). | ||
DoAndReturn(func(_, _ any) (*dbfs.CreateResponse, error) { | ||
return &dbfs.CreateResponse{ | ||
Handle: 123, | ||
}, nil | ||
}) | ||
|
||
w := workspaces.New() | ||
w.Dbfs = m | ||
|
||
h, err := w.Dbfs.Create(ctx, dbfs.Create{ | ||
Path: "/a/b/c", | ||
}) | ||
assert.NoError(t, err) | ||
|
||
assert.Equal(t, int64(123), h.Handle) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module sample | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/databricks/databricks-sdk-go v0.0.0 | ||
github.com/golang/mock v1.6.0 | ||
github.com/stretchr/testify v1.8.1 | ||
) | ||
|
||
require ( | ||
cloud.google.com/go/compute v1.6.1 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/go-querystring v1.1.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
go.opencensus.io v0.23.0 // indirect | ||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect | ||
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect | ||
golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26 // indirect | ||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect | ||
google.golang.org/api v0.82.0 // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/genproto v0.0.0-20220527130721-00d5c0f3be58 // indirect | ||
google.golang.org/grpc v1.46.2 // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
gopkg.in/ini.v1 v1.66.6 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) | ||
|
||
replace github.com/databricks/databricks-sdk-go v0.0.0 => ../.. |
Oops, something went wrong.