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

sharing tests: mock api calls so it doesnt stuck into possible unwanted errors #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions sharing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ import (
"testing"

"github.com/stretchr/testify/assert"
httpmock "gopkg.in/jarcoal/httpmock.v1"
)

func TestSharing_CreateSharedLink(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()

httpmock.RegisterResponder("POST", "https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings",
httpmock.NewStringResponder(200, `{"path":"/hello.txt"}`))

c := client()
out, err := c.Sharing.CreateSharedLink(&CreateSharedLinkInput{
Path: "/hello.txt",
Expand All @@ -17,6 +24,12 @@ func TestSharing_CreateSharedLink(t *testing.T) {
}

func TestSharing_ListSharedFolder(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()

httpmock.RegisterResponder("POST", "https://api.dropboxapi.com/2/sharing/list_folders",
httpmock.NewStringResponder(200, `{"entries":[{"name":"foo", "shared_folder_id":"321321"}]}`))

c := client()
out, err := c.Sharing.ListSharedFolders(&ListSharedFolderInput{
Limit: 1,
Expand Down