mirror of
https://github.com/larksuite/cli.git
synced 2026-07-06 16:18:05 +08:00
* feat: add stable bot-only cli e2e subset Change-Id: I62edf59d179e407954f65f82e94cf5dcf4938080 * fix: address review comments on stable cli e2e tests Change-Id: I4436100c30adf2694cd06953961f8d77f576fc1e * fix: reduce flakiness in drive and im e2e helpers Change-Id: I51e77d857f1fd9aec5ee34adf5045cc695239f21 * fix: document missing drive cleanup support Change-Id: I3d4f034145bd69fb7640e707fcda05146b8754c7 * style: unify e2e cleanup comments Change-Id: I40d906c9168754ad71ef9fb770ff4c340fc19beb * test: update e2e assertions Change-Id: I73c21b4b38d4ced7ea27cb327075957ec2b9a2a2 * test: stabilize cli e2e bot-only coverage Change-Id: Ied897c37c4f42e446d55d110461aa34ae198195d
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package docs
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
clie2e "github.com/larksuite/cli/tests/cli_e2e"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
// TestDocs_CreateAndFetchWorkflow tests the create and fetch lifecycle.
|
|
func TestDocs_CreateAndFetchWorkflow(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
|
t.Cleanup(cancel)
|
|
|
|
suffix := clie2e.GenerateSuffix()
|
|
folderName := "lark-cli-e2e-docs-folder-" + suffix
|
|
docTitle := "lark-cli-e2e-docs-" + suffix
|
|
docContent := "# Test Document\n\nThis document was created by lark-cli e2e test."
|
|
|
|
folderToken := createDocsFolderWithRetry(t, ctx, folderName)
|
|
var docToken string
|
|
|
|
t.Run("create", func(t *testing.T) {
|
|
docToken = createDocWithRetry(t, ctx, folderToken, docTitle, docContent)
|
|
})
|
|
|
|
t.Run("fetch", func(t *testing.T) {
|
|
require.NotEmpty(t, docToken, "document token should be created before fetch")
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{
|
|
"docs", "+fetch",
|
|
"--doc", docToken,
|
|
},
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 0)
|
|
result.AssertStdoutStatus(t, true)
|
|
assert.Equal(t, docTitle, gjson.Get(result.Stdout, "data.title").String())
|
|
})
|
|
}
|