chore: import upstream snapshot with attribution
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / results (push) Has been cancelled
CI / deadcode (push) Has been cancelled
CI / e2e-live (push) Has been cancelled
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / results (push) Has been cancelled
CI / deadcode (push) Has been cancelled
CI / e2e-live (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# Demo Coverage Template
|
||||
|
||||
> This file is a demo template only.
|
||||
> It shows the expected `coverage.md` shape for real domains under `tests/cli_e2e/{domain}`.
|
||||
> The numbers, command list, and coverage status below are illustrative, not authoritative.
|
||||
> `tests/cli_e2e/demo/` is reference material and is not part of formal CLI E2E coverage accounting.
|
||||
> `lark-cli demo --help` does not exist, so this file cannot be recomputed from live domain help output.
|
||||
|
||||
## Metrics
|
||||
|
||||
- Denominator: 8 leaf commands
|
||||
- Covered: 3
|
||||
- Coverage: 37.5%
|
||||
|
||||
## Summary
|
||||
|
||||
- Purpose: show humans and AI agents how to maintain a per-domain coverage file even when the directory is documentation-only and not backed by a real `lark-cli demo` command tree.
|
||||
- TestDemo_TaskLifecycle: demonstrates one minimal task lifecycle workflow for documentation purposes.
|
||||
- TestDemo_TaskLifecycle/create: runs `task +create` with `summary` and `description`, captures the returned `taskGUID`, and registers parent cleanup for later teardown.
|
||||
- TestDemo_TaskLifecycle/update: runs `task +update --task-id <guid>` and mutates both `summary` and `description` on the created task.
|
||||
- TestDemo_TaskLifecycle/get: runs `task tasks get` for the same task and asserts the persisted `guid`, updated `summary`, and updated `description`.
|
||||
- Cleanup note: `task tasks delete` is executed in `parentT.Cleanup`, but this template intentionally keeps cleanup-only execution marked uncovered so workflow assertions remain distinct from teardown mechanics.
|
||||
- Demo-only gap note: `task +complete`, `task +reopen`, `task +assign`, and `task +get-my-tasks` are intentionally left as uncovered examples for a minimal template.
|
||||
|
||||
## Command Table
|
||||
|
||||
| Status | Cmd | Type | Testcase | Key parameter shapes | Notes / uncovered reason |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| ✓ | task +create | shortcut | task_lifecycle_test.go::TestDemo_TaskLifecycle/create | basic create; summary; description | demo example |
|
||||
| ✓ | task +update | shortcut | task_lifecycle_test.go::TestDemo_TaskLifecycle/update | --task-id; update summary; update description | demo example |
|
||||
| ✓ | task tasks get | api | task_lifecycle_test.go::TestDemo_TaskLifecycle/get | task_guid in --params | demo example |
|
||||
| ✕ | task tasks delete | api | | none | cleanup exists in parentT.Cleanup, but demo coverage intentionally treats cleanup-only execution as uncovered |
|
||||
| ✕ | task +complete | shortcut | | none | not shown in this minimal lifecycle example |
|
||||
| ✕ | task +reopen | shortcut | | none | not shown in this minimal lifecycle example |
|
||||
| ✕ | task +assign | shortcut | | none | example of a user-identity-sensitive command; requires real user fixtures |
|
||||
| ✕ | task +get-my-tasks | shortcut | | none | example of a current-user-dependent command; often unavailable in bot-only environments |
|
||||
|
||||
## Notes
|
||||
|
||||
- In a real domain, recompute the denominator from live `lark-cli --help` exploration instead of copying this file.
|
||||
- Replace demo rows with real command inventory for that domain.
|
||||
- Keep skipped commands unchecked; reuse the `t.Skip(...)` reason as the uncovered reason.
|
||||
@@ -0,0 +1,90 @@
|
||||
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package demo
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
func TestDemo_TaskLifecycle(t *testing.T) {
|
||||
parentT := t
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
t.Cleanup(cancel)
|
||||
|
||||
suffix := time.Now().UTC().Format("20060102-150405")
|
||||
createdSummary := "lark-cli-e2e-create-" + suffix
|
||||
updatedSummary := "lark-cli-e2e-update-" + suffix
|
||||
createdDescription := "created by tests/cli_e2e/demo"
|
||||
updatedDescription := "updated by tests/cli_e2e/demo"
|
||||
|
||||
var taskGUID string
|
||||
|
||||
t.Run("create as bot", func(t *testing.T) {
|
||||
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
||||
Args: []string{"task", "+create"},
|
||||
DefaultAs: "bot",
|
||||
Data: map[string]any{
|
||||
"summary": createdSummary,
|
||||
"description": createdDescription,
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
result.AssertExitCode(t, 0)
|
||||
result.AssertStdoutStatus(t, true)
|
||||
taskGUID = gjson.Get(result.Stdout, "data.guid").String()
|
||||
require.NotEmpty(t, taskGUID, "stdout:\n%s", result.Stdout)
|
||||
|
||||
parentT.Cleanup(func() {
|
||||
cleanupCtx, cancel := clie2e.CleanupContext()
|
||||
defer cancel()
|
||||
|
||||
deleteResult, deleteErr := clie2e.RunCmd(cleanupCtx, clie2e.Request{
|
||||
Args: []string{"task", "tasks", "delete"},
|
||||
DefaultAs: "bot",
|
||||
Params: map[string]any{"task_guid": taskGUID},
|
||||
Yes: true,
|
||||
})
|
||||
clie2e.ReportCleanupFailure(parentT, "delete task "+taskGUID, deleteResult, deleteErr)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("update as bot", func(t *testing.T) {
|
||||
require.NotEmpty(t, taskGUID, "task GUID should be created before update")
|
||||
|
||||
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
||||
Args: []string{"task", "+update", "--task-id", taskGUID},
|
||||
DefaultAs: "bot",
|
||||
Data: map[string]any{
|
||||
"summary": updatedSummary,
|
||||
"description": updatedDescription,
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
result.AssertExitCode(t, 0)
|
||||
result.AssertStdoutStatus(t, true)
|
||||
})
|
||||
|
||||
t.Run("get as bot", func(t *testing.T) {
|
||||
require.NotEmpty(t, taskGUID, "task GUID should be created before get")
|
||||
|
||||
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
||||
Args: []string{"task", "tasks", "get"},
|
||||
DefaultAs: "bot",
|
||||
Params: map[string]any{"task_guid": taskGUID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
result.AssertExitCode(t, 0)
|
||||
result.AssertStdoutStatus(t, true)
|
||||
assert.Equal(t, taskGUID, gjson.Get(result.Stdout, "data.task.guid").String())
|
||||
assert.Equal(t, updatedSummary, gjson.Get(result.Stdout, "data.task.summary").String())
|
||||
assert.Equal(t, updatedDescription, gjson.Get(result.Stdout, "data.task.description").String())
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user