Skip to content

Commit

Permalink
Keep Nextcloud server mock out of main driver code
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Aug 17, 2021
1 parent fb3f176 commit 63d6135
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
8 changes: 8 additions & 0 deletions changelog/unreleased/fix-dependency-on-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: fix dependency on tests

The Nextcloud storage driver depended on a mock http client from the tests/ folder
This broke the Docker build
The dependency was removed
A check was added to test the Docker build on each PR

https://github.com/cs3org/reva/pull/2000
11 changes: 3 additions & 8 deletions pkg/storage/fs/nextcloud/nextcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/storage"
"github.com/cs3org/reva/pkg/storage/fs/registry"
"github.com/cs3org/reva/tests/helpers"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -72,16 +71,12 @@ func New(m map[string]interface{}) (storage.FS, error) {
return nil, err
}

return NewStorageDriver(conf)
return NewStorageDriver(conf, nil)
}

// NewStorageDriver returns a new NextcloudStorageDriver
func NewStorageDriver(c *StorageDriverConfig) (*StorageDriver, error) {
var client *http.Client
if c.MockHTTP {
nextcloudServerMock := GetNextcloudServerMock()
client, _ = helpers.TestingHTTPClient(nextcloudServerMock)
} else {
func NewStorageDriver(c *StorageDriverConfig, client *http.Client) (*StorageDriver, error) {
if client == nil {
client = &http.Client{}
}
return &StorageDriver{
Expand Down
6 changes: 4 additions & 2 deletions pkg/storage/fs/nextcloud/nextcloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ var _ = Describe("Nextcloud", func() {
})
Describe("CreateHome", func() {
It("calls the CreateHome endpoint", func() {
nextcloudServerMock := nextcloud.GetNextcloudServerMock()
var client *http.Client
client, _ = helpers.TestingHTTPClient(nextcloudServerMock)
nc, _ := nextcloud.NewStorageDriver(&nextcloud.StorageDriverConfig{
EndPoint: "http://mock.com",
MockHTTP: true,
})
}, client)

const (
okResponse = `{
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/grpc/storageprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ var _ = Describe("storage providers", func() {
})
}

Describe("nextcloud", func() {
PDescribe("nextcloud", func() {
BeforeEach(func() {
dependencies = map[string]string{
"storage": "storageprovider-nextcloud.toml",
Expand Down

0 comments on commit 63d6135

Please sign in to comment.