You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: scheduled_changefeed_test.go
    path of file: ./repos/cockroach/pkg/ccl/changefeedccl
    
    the code of the file until where you have to start completion: // Copyright 2022 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
//     https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt

package changefeedccl

import (
	"context"
	gosql "database/sql"
	"fmt"
	"net/url"
	"strconv"
	"strings"
	"testing"
	"time"

	"github.com/cockroachdb/cockroach/pkg/base"
	"github.com/cockroachdb/cockroach/pk
    
func TestSerializesScheduledChangefeedExecutionArgs(t *testing.T) {
	defer leaktest.AfterTest(t)()
	defer log.Scope(t).Close(t)

	th, cleanup := newTestHelper(t)
	defer cleanup()

	th.sqlDB.Exec(t, `CREATE TABLE foo (a INT, b STRING)`)

	type expectedSchedule struct {
		nameRe         string
		changefeedStmt string
		period         time.Duration
		runsNow        bool
		shownStmt      string
	}

	testCases := []struct {
		name      string
		query     string
		queryArgs []interface{}
		es        expectedSchedule
		errMsg    string
	}{
		{
			name:  "changefeed",
			query: "CREATE SCHEDULE FOR CHANGEFEED d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown' WITH initial_scan='only' RECURRING '@hourly'",
			es: expectedSchedule{
				nameRe:         "CHANGEFEED .+",
				changefeedStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown' WITH OPTIONS (initial_scan = 'only')",
				shownStmt:      "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=redacted' WITH OPTIONS (initial_scan = 'only')",
				period:         time.Hour,
			},
		},
		{
			name:  "changefeed-qualifies-names",
			query: "CREATE SCHEDULE FOR CHANGEFEED foo INTO 'webhook-https://0/changefeed' WITH initial_scan = 'only' RECURRING '@hourly'",
			es: expectedSchedule{
				nameRe:         "CHANGEFEED .+",
				changefeedStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed' WITH OPTIONS (initial_scan = 'only')",
				period:         time.Hour,
			},
		},
		{
			name: "changefeed-with-options",
			query: `
		CREATE SCHEDULE 'foo-changefeed'
		FOR CHANGEFEED  foo
		INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown'
		WITH format='JSON'
		RECURRING '@hourly' WITH SCHEDULE OPTIONS on_execution_failure = 'pause', first_run=$1
		`,
			queryArgs: []interface{}{th.env.Now()},
			es: expectedSchedule{
				nameRe:         "foo-changefeed",
				changefeedStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown' WITH OPTIONS (format = 'JSON', initial_scan = 'only')",
				shownStmt:      "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=redacted' WITH OPTIONS (format = 'JSON', initial_scan = 'only')",
				period:         time.Hour,
				runsNow:        true,
			},
		},
		{
			name: "changefeed-expressions",
			query: `
		CREATE SCHEDULE 'foo-changefeed'
		FOR CHANGEFEED INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown'
		WITH format='JSON', initial_scan = 'only', schema_change_policy='stop'
		AS SELECT * FROM foo
		RECURRING '@hourly' WITH SCHEDULE OPTIONS on_execution_failure = 'pause', first_run=$1
		`,
			queryArgs: []interface{}{th.env.Now()},
			es: expectedSchedule{
				nameRe:         "foo-changefeed",
				changefeedStmt: "CREATE CHANGEFEED INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown' WITH OPTIONS (format = 'JSON', initial_scan = 'only', schema_change_policy = 'stop') AS SELECT * FROM d.public.foo",
				shownStmt:      "CREATE CHANGEFEED INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=redacted' WITH OPTIONS (format = 'JSON', initial_scan = 'only', schema_change_policy = 'stop') AS SELECT * FROM d.public.foo",
				period:         time.Hour,
				runsNow:        true,
			},
		},
	}

	for _, tc := range testCases {
		t.Run(fmt.Sprintf(tc.name), func(t *testing.T) {
			defer th.clearSchedules(t)

			sj, err := th.createChangefeedSchedule(t, tc.query, tc.queryArgs...)
			if len(tc.errMsg) > 0 {
				require.True(t, testutils.IsError(err, tc.errMsg),
					"expected error to match %q, found %q instead", tc.errMsg, err.Error())
				return
			}

			require.NoError(t, err)

			expectedSchedule := tc.es
			changefeedStmt := getScheduledChangefeedStatement(t, sj.ExecutionArgs())
			require.Equal(t, expectedSchedule.changefeedStmt, changefeedStmt)

			frequency, err := sj.Frequency()
			require.NoError(t, err)
			require.EqualValues(t, expectedSchedule.period, frequency, expectedSchedule)

			if expectedSchedule.runsNow {
				require.EqualValues(t, th.env.Now().Round(time.Microsecond), sj.ScheduledRunTime())
			}

			var shownStmt string
			th.sqlDB.QueryRow(t, `SELECT command->>'changefeed_statement' FROM [SHOW SCHEDULE $1]`,
				sj.ScheduleID()).Scan(&shownStmt)

			if expectedSchedule.shownStmt != "" {
				require.Equal(t, expectedSchedule.shownStmt, shownStmt)
			} else {
				require.Equal(t, expectedSchedule.changefeedStmt, shownStmt)
			}
		})
	}
}