Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep Nextcloud server mock out of main driver code #2000

Merged
merged 3 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ def buildOnly():
"steps": [
licenseScanStep(),
makeStep("ci"),
{
"name": "Docker build",
"image": "plugins/docker",
"settings": {
"repo": "n/a",
"dry_run": "true",
"dockerfile": "Dockerfile.revad",
}
},
lintStep(),
{
"name": "changelog",
Expand Down
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