MCPcopy Create free account
hub / github.com/openclaw/gogcli / TestDocsCreateCopyCat_Text

Function TestDocsCreateCopyCat_Text

internal/cmd/docs_commands_test.go:710–762  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

708}
709
710func TestDocsCreateCopyCat_Text(t *testing.T) {
711 t.Parallel()
712
713 export := func(context.Context, *drive.Service, string, string) (*http.Response, error) {
714 return &http.Response{
715 StatusCode: http.StatusOK,
716 Body: io.NopCloser(strings.NewReader("doc text")),
717 }, nil
718 }
719
720 srv := httptest.NewServer(docsCreateCopyCatHandler())
721 defer srv.Close()
722
723 svc, err := drive.NewService(context.Background(),
724 option.WithoutAuthentication(),
725 option.WithHTTPClient(srv.Client()),
726 option.WithEndpoint(srv.URL+"/"),
727 )
728 if err != nil {
729 t.Fatalf("NewService: %v", err)
730 }
731
732 docSvc, err := docs.NewService(context.Background(),
733 option.WithoutAuthentication(),
734 option.WithHTTPClient(srv.Client()),
735 option.WithEndpoint(srv.URL+"/"),
736 )
737 if err != nil {
738 t.Fatalf("NewDocsService: %v", err)
739 }
740 flags := &RootFlags{Account: "a@b.com"}
741 var stdout, stderr bytes.Buffer
742 ctx := withDriveTestOperations(newCmdRuntimeOutputContext(t, &stdout, &stderr), svc, nil, export)
743 ctx = withDocsTestService(ctx, docSvc)
744
745 createCmd := &DocsCreateCmd{}
746 if err := runKong(t, createCmd, []string{"Doc"}, ctx, flags); err != nil {
747 t.Fatalf("create: %v", err)
748 }
749
750 copyCmd := &DocsCopyCmd{}
751 if err := runKong(t, copyCmd, []string{"doc1", "Copy"}, ctx, flags); err != nil {
752 t.Fatalf("copy: %v", err)
753 }
754
755 catCmd := &DocsCatCmd{}
756 if err := runKong(t, catCmd, []string{"doc1"}, ctx, flags); err != nil {
757 t.Fatalf("cat: %v", err)
758 }
759 if !strings.Contains(stdout.String(), "doc text") || !strings.Contains(stdout.String(), "id\tdoc1") {
760 t.Fatalf("unexpected output: %q", stdout.String())
761 }
762}

Callers

nothing calls this directly

Calls 7

docsCreateCopyCatHandlerFunction · 0.85
withDriveTestOperationsFunction · 0.85
withDocsTestServiceFunction · 0.85
runKongFunction · 0.85
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected