<commit_before>package main

import (
	"context"
	"fmt"
	"net/http"
	"testing"
	"time"

	"github.com/stretchr/testify/require"
	"go.skia.org/infra/autoroll/go/config"
	"go.skia.org/infra/autoroll/go/recent_rolls"
	"go.skia.org/infra/go/autoroll"
	"go.skia.org/infra/go/deepequal/assertdeep"
	"go.skia.org/infra/go/ds"
	"go.skia.org/infra/go/ds/testutil"
	"go.skia.org/infra/go/git"
	git_testutils "go.skia.org/infra/go/git/testutils"
	gitiles_testutils "go.skia.org/infra/go/gitiles/testutils"
	"go.skia.org/infra/go/jsonutils"
	"go.skia.org/infra/go/mockhttpclient"
	"go.skia.org/infra/go/testutils/unittest"
)

func setup(t *testing.T) (context.Context, *AutoRoller, *git_testutils.GitBuilder, *gitiles_testutils.MockRepo, func()) {
	unittest.LargeTest(t)
	ctx := context.Background()
	testutil.InitDatastore(t, ds.KIND_AUTOROLL_ROLL, ds.KIND_AUTOROLL_STATUS)
	gb := git_testutils.GitInit(t, ctx)
	urlmock := mockhttpclient.NewURLMock()
	mockChild := gitiles_testutils.NewMockRepo(t, gb.RepoUrl(), git.GitDir(gb.Dir()), urlmock)
	a, err := NewAutoRoller(ctx, &config.Config{
		ChildDisplayName: "test-child",
		RepoManager: &config.Config_Google3RepoManager{
			Google3RepoManager: &config.Google3RepoManagerConfig{
				ChildBranch: git.DefaultBranch,
				ChildRepo:   gb.RepoUrl(),
			},
		},
		ParentDisplayName: "test-parent",
		RollerName:        "test-roller",
	}, urlmock.Client(), nil)
	require.NoError(t, err)
	a.Start(ctx, time.Second, time.Second)
	return ctx, a, gb, mockChild, func() {<commit_msg>[autoroll] Fix (?) flaky google3_test<commit_after>package main

import (
	"context"
	"fmt"
	"net/http"
	"testing"
	"time"

	"github.com/stretchr/testify/require"
	"go.skia.org/infra/autoroll/go/config"
	"go.skia.org/infra/autoroll/go/recent_rolls"
	"go.skia.org/infra/go/autoroll"
	"go.skia.org/infra/go/deepequal/assertdeep"
	"go.skia.org/infra/go/ds"
	"go.skia.org/infra/go/ds/testutil"
	"go.skia.org/infra/go/git"
	git_testutils "go.skia.org/infra/go/git/testutils"
	gitiles_testutils "go.skia.org/infra/go/gitiles/testutils"
	"go.skia.org/infra/go/jsonutils"
	"go.skia.org/infra/go/mockhttpclient"
	"go.skia.org/infra/go/testutils/unittest"
)

func setup(t *testing.T) (context.Context, *AutoRoller, *git_testutils.GitBuilder, *gitiles_testutils.MockRepo, func()) {
	unittest.LargeTest(t)
	ctx := context.Background()
	testutil.InitDatastore(t, ds.KIND_AUTOROLL_ROLL, ds.KIND_AUTOROLL_STATUS)
	gb := git_testutils.GitInit(t, ctx)
	urlmock := mockhttpclient.NewURLMock()
	mockChild := gitiles_testutils.NewMockRepo(t, gb.RepoUrl(), git.GitDir(gb.Dir()), urlmock)
	a, err := NewAutoRoller(ctx, &config.Config{
		ChildDisplayName: "test-child",
		RepoManager: &config.Config_Google3RepoManager{
			Google3RepoManager: &config.Google3RepoManagerConfig{
				ChildBranch: git.DefaultBranch,
				ChildRepo:   gb.RepoUrl(),
			},
		},
		ParentDisplayName: "test-parent",
		RollerName:        "test-roller",
	}, urlmock.Client(), nil)
	require.NoError(t, err)
	return ctx, a, gb, mockChild, func() {
{'fraction_non_alphanumeric': 0.16101131071190952, 'fraction_numerical': 0.002328675981370592, 'mean_word_length': 4.942687747035573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7239322', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1258, 'n_words': 156}