bf9395e022
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
68 lines
1.7 KiB
Go
68 lines
1.7 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package calendar
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
"testing"
|
|
"time"
|
|
|
|
clie2e "github.com/larksuite/cli/tests/cli_e2e"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
func getPrimaryCalendarID(t *testing.T, ctx context.Context) string {
|
|
t.Helper()
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{"calendar", "calendars", "primary"},
|
|
DefaultAs: "bot",
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 0)
|
|
result.AssertStdoutStatus(t, true)
|
|
|
|
calendarID := gjson.Get(result.Stdout, "data.calendars.0.calendar.calendar_id").String()
|
|
require.NotEmpty(t, calendarID, "stdout:\n%s", result.Stdout)
|
|
return calendarID
|
|
}
|
|
|
|
func getCurrentUserPrimaryCalendarID(t *testing.T, ctx context.Context) string {
|
|
t.Helper()
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{"calendar", "calendars", "primary"},
|
|
DefaultAs: "user",
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 0)
|
|
result.AssertStdoutStatus(t, true)
|
|
|
|
calendarID := gjson.Get(result.Stdout, "data.calendars.0.calendar.calendar_id").String()
|
|
require.NotEmpty(t, calendarID, "stdout:\n%s", result.Stdout)
|
|
return calendarID
|
|
}
|
|
|
|
func getCurrentUserOpenIDForCalendar(t *testing.T, ctx context.Context) string {
|
|
t.Helper()
|
|
|
|
result, err := clie2e.RunCmd(ctx, clie2e.Request{
|
|
Args: []string{"contact", "+get-user"},
|
|
DefaultAs: "user",
|
|
})
|
|
require.NoError(t, err)
|
|
result.AssertExitCode(t, 0)
|
|
result.AssertStdoutStatus(t, true)
|
|
|
|
openID := gjson.Get(result.Stdout, "data.user.open_id").String()
|
|
require.NotEmpty(t, openID, "stdout:\n%s", result.Stdout)
|
|
return openID
|
|
}
|
|
|
|
func unixSecondsRFC3339(t time.Time) string {
|
|
return strconv.FormatInt(t.Unix(), 10)
|
|
}
|