MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestPutJSONDefaultTargetUsesComputedPath

Function TestPutJSONDefaultTargetUsesComputedPath

cmd/put_test.go:770–802  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

768}
769
770func TestPutJSONDefaultTargetUsesComputedPath(t *testing.T) {
771 tmpFile := filepath.Join(t.TempDir(), "local.txt")
772 if err := os.WriteFile(tmpFile, []byte("test"), 0644); err != nil {
773 t.Fatal(err)
774 }
775
776 mock := &mockFilesClient{
777 uploadFn: func(arg *files.UploadArg, content io.Reader) (*files.FileMetadata, error) {
778 if arg.Path != "/local.txt" {
779 t.Fatalf("upload path = %q, want /local.txt", arg.Path)
780 }
781 if _, err := io.ReadAll(content); err != nil {
782 t.Fatal(err)
783 }
784 return putFileMetadata(arg.Path, 4), nil
785 },
786 }
787 stubFilesClient(t, mock)
788
789 var stdout bytes.Buffer
790 cmd := testPutJSONCmd(&stdout, nil)
791 if err := put(cmd, []string{tmpFile}); err != nil {
792 t.Fatalf("put error: %v", err)
793 }
794
795 got := decodePutOutput(t, &stdout)
796 if got.Input.Target != "/local.txt" {
797 t.Fatalf("target = %q, want /local.txt", got.Input.Target)
798 }
799 if got.Results[0].Input.Target != "/local.txt" {
800 t.Fatalf("result target = %q, want /local.txt", got.Results[0].Input.Target)
801 }
802}
803
804func TestPutJSONIfExistsSkipOutputsSkippedResult(t *testing.T) {
805 tmpFile := filepath.Join(t.TempDir(), "test.txt")

Callers

nothing calls this directly

Calls 5

putFileMetadataFunction · 0.85
stubFilesClientFunction · 0.85
testPutJSONCmdFunction · 0.85
putFunction · 0.85
decodePutOutputFunction · 0.85

Tested by

no test coverage detected