Skip to content

Commit edae0b7

Browse files
committed
Fix: compilation errors
1 parent e1900d1 commit edae0b7

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

examples-copier/services/github_read_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import (
55
"testing"
66

77
"github.com/google/go-github/v48/github"
8-
"github.com/mongodb/code-example-tooling/code-copier/configs"
98
"github.com/mongodb/code-example-tooling/code-copier/services"
10-
"github.com/mongodb/code-example-tooling/code-copier/types"
119
"github.com/stretchr/testify/require"
1210

1311
test "github.com/mongodb/code-example-tooling/code-copier/tests"
@@ -29,6 +27,13 @@ func stubContentsForBothOwners(path, contentB64 string, owner, repo string) {
2927
test.MockContentsEndpoint("REPO_OWNER", "REPO_NAME", path, contentB64)
3028
}
3129

30+
// LEGACY TESTS - These tests are for legacy code that was removed in commit a64726c
31+
// The RetrieveAndParseConfigFile function was removed as part of the migration to YAML config
32+
// and the new pattern-matching system. These tests are commented out but kept for reference.
33+
//
34+
// If you need to test config loading, see config_loader_test.go for the new YAML-based system.
35+
36+
/*
3237
func TestRetrieveAndParseConfigFile_Valid(t *testing.T) {
3338
_ = test.WithHTTPMock(t)
3439
owner, repo := ensureEnv(t)
@@ -84,6 +89,7 @@ func TestRetrieveAndParseConfigFile_InvalidJSON(t *testing.T) {
8489
require.Error(t, err, "invalid JSON must return an error")
8590
require.Nil(t, got)
8691
}
92+
*/
8793

8894
func TestRetrieveFileContents_Success(t *testing.T) {
8995
_ = test.WithHTTPMock(t)
@@ -101,6 +107,7 @@ func TestRetrieveFileContents_Success(t *testing.T) {
101107
require.Contains(t, *rc.Content, b64(payload))
102108
}
103109

110+
/*
104111
// Test that Retrieve and Parse round-trips with one entry
105112
func TestRetrieveAndParseConfigFile_RoundTripMinimal(t *testing.T) {
106113
_ = test.WithHTTPMock(t)
@@ -137,3 +144,4 @@ func TestRetrieveAndParseConfigFile_RoundTripMinimal(t *testing.T) {
137144
require.Equal(t, min[0].TargetDirectory, got[0].TargetDirectory)
138145
require.Equal(t, min[0].RecursiveCopy, got[0].RecursiveCopy)
139146
}
147+
*/

examples-copier/services/github_write_to_target_test.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ func TestMain(m *testing.M) {
5757
os.Exit(code)
5858
}
5959

60+
// LEGACY TESTS - These tests are for legacy code that was removed in commit a64726c
61+
// The AddToRepoAndFilesMap and IterateFilesForCopy functions were removed as part of the
62+
// migration to the new pattern-matching system. These tests are commented out but kept for reference.
63+
//
64+
// The new system uses pattern matching rules defined in YAML config files.
65+
// See pattern_matcher_test.go for tests of the new system.
66+
67+
/*
6068
func TestAddToRepoAndFilesMap_NewEntry(t *testing.T) {
6169
services.FilesToUpload = nil
6270
@@ -209,6 +217,7 @@ func TestIterateFilesForCopy_RecursiveVsNonRecursive(t *testing.T) {
209217
})
210218
}
211219
}
220+
*/
212221

213222
func TestAddFilesToTargetRepoBranch_Succeeds(t *testing.T) {
214223
_ = test.WithHTTPMock(t)
@@ -539,10 +548,10 @@ func TestPriority_Strategy_ConfigOverridesEnv_And_MessageFallbacks(t *testing.T)
539548
}
540549

541550
services.FilesToUpload = map[types.UploadKey]types.UploadFileContent{
542-
{RepoName: repo, BranchPath: "refs/heads/" + baseBranch}: {TargetBranch: baseBranch, Content: files},
551+
{RepoName: repo, BranchPath: "refs/heads/" + baseBranch, CommitStrategy: cfg.CopierCommitStrategy}: {TargetBranch: baseBranch, Content: files},
543552
}
544553

545-
services.AddFilesToTargetRepoBranch(types.ConfigFileType{cfg})
554+
services.AddFilesToTargetRepoBranch() // No longer takes parameters - uses FilesToUpload map
546555

547556
info := httpmock.GetCallCountInfo()
548557
require.Equal(t, 1, info["GET "+baseRefURL])
@@ -615,10 +624,10 @@ func TestPriority_PRTitleDefaultsToCommitMessage_And_NoAutoMergeWhenConfigPresen
615624
Name: github.String("only.txt"), Path: github.String("only.txt"),
616625
Content: github.String(base64.StdEncoding.EncodeToString([]byte("y"))),
617626
}}
618-
cfg := types.Configs{TargetRepo: repo, TargetBranch: baseBranch /* MergeWithoutReview: false (zero value) */}
619-
services.FilesToUpload = map[types.UploadKey]types.UploadFileContent{{RepoName: repo, BranchPath: "refs/heads/" + baseBranch, RuleName: "", CommitStrategy: ""}: {TargetBranch: baseBranch, Content: files}}
627+
// cfg := types.Configs{TargetRepo: repo, TargetBranch: baseBranch /* MergeWithoutReview: false (zero value) */}
628+
services.FilesToUpload = map[types.UploadKey]types.UploadFileContent{{RepoName: repo, BranchPath: "refs/heads/" + baseBranch, RuleName: "", CommitStrategy: "pr"}: {TargetBranch: baseBranch, Content: files}}
620629

621-
services.AddFilesToTargetRepoBranch(types.ConfigFileType{cfg})
630+
services.AddFilesToTargetRepoBranch() // No longer takes parameters - uses FilesToUpload map
622631

623632
// Ensure a PR was created but no merge occurred
624633
require.Equal(t, 1, test.CountByMethodAndURLRegexp("POST", regexp.MustCompile(`/pulls$`)))

0 commit comments

Comments
 (0)