Skip to content

Commit 1ec083c

Browse files
[Autoloop: python-to-go-migration] Iteration 109: Extend 6 thin Go test suites with edge cases
Run: https://github.com/githubnext/apm/actions/runs/25993682802 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f5b08de commit 1ec083c

7 files changed

Lines changed: 366 additions & 2 deletions

File tree

benchmarks/migration-status.json

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"original_python_lines": 87626,
3-
"migrated_python_lines": 869215,
3+
"migrated_python_lines": 869537,
44
"migrated_modules": [
55
{
66
"module": "deps/apm_resolver",
@@ -16364,6 +16364,48 @@
1636416364
"python_lines": 30,
1636516365
"status": "test-migrated",
1636616366
"notes": "Extended intutils_test.go: no-scheme-no-slash, multi-path HTTPS, both suffixes, empty string"
16367+
},
16368+
{
16369+
"module": "test/commands/view/extended-iter109",
16370+
"go_package": "internal/commands/view",
16371+
"python_lines": 76,
16372+
"status": "test-migrated",
16373+
"notes": "Extended view_test.go with ViewOptions, PackageInfo, parseSimpleYAML edge cases"
16374+
},
16375+
{
16376+
"module": "test/core/experimental/extended-iter109",
16377+
"go_package": "internal/core/experimental",
16378+
"python_lines": 48,
16379+
"status": "test-migrated",
16380+
"notes": "Extended experimental_test.go with hint, immutability, DisplayName edge cases"
16381+
},
16382+
{
16383+
"module": "test/deps/installedpkg/extended-iter109",
16384+
"go_package": "internal/deps/installedpkg",
16385+
"python_lines": 42,
16386+
"status": "test-migrated",
16387+
"notes": "Extended installedpkg_test.go with zero value, depth levels, commit formats"
16388+
},
16389+
{
16390+
"module": "test/integration/coverage/extended-iter109",
16391+
"go_package": "internal/integration/coverage",
16392+
"python_lines": 54,
16393+
"status": "test-migrated",
16394+
"notes": "Extended coverage_test.go with DispatchEntry, multi-special, all-special cases"
16395+
},
16396+
{
16397+
"module": "test/install/mcpconflicts/extended-iter109",
16398+
"go_package": "internal/install/mcp/mcpconflicts",
16399+
"python_lines": 50,
16400+
"status": "test-migrated",
16401+
"notes": "Extended mcpconflicts_test.go with URL, env, header, zero-value, error interface tests"
16402+
},
16403+
{
16404+
"module": "test/install/request/extended-iter109",
16405+
"go_package": "internal/install/request",
16406+
"python_lines": 52,
16407+
"status": "test-migrated",
16408+
"notes": "Extended request_test.go with zero value, skill subset, frozen, OnlyPackages tests"
1636716409
}
1636816410
],
1636916411
"last_updated": "2026-05-17T08:23:58Z",
@@ -16403,4 +16445,4 @@
1640316445
"status": "migrated"
1640416446
}
1640516447
]
16406-
}
16448+
}

internal/commands/view/view_test.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,79 @@ func TestViewOptions(t *testing.T) {
5252
t.Errorf("unexpected Package %q", opts.Package)
5353
}
5454
}
55+
56+
func TestViewOptionsAllFields(t *testing.T) {
57+
opts := ViewOptions{
58+
ProjectRoot: "/home/user/project",
59+
Package: "owner/repo",
60+
Field: "versions",
61+
Format: "json",
62+
Verbose: true,
63+
}
64+
if opts.ProjectRoot != "/home/user/project" {
65+
t.Errorf("ProjectRoot mismatch: %q", opts.ProjectRoot)
66+
}
67+
if opts.Field != "versions" {
68+
t.Errorf("Field mismatch: %q", opts.Field)
69+
}
70+
if !opts.Verbose {
71+
t.Error("Verbose should be true")
72+
}
73+
}
74+
75+
func TestParseSimpleYAMLMultipleValues(t *testing.T) {
76+
data := []byte("key1: val1\nkey2: val2\nkey3: val3\n")
77+
var out map[string]interface{}
78+
if err := parseSimpleYAML(data, &out); err != nil {
79+
t.Fatalf("unexpected error: %v", err)
80+
}
81+
if len(out) != 3 {
82+
t.Errorf("expected 3 entries, got %d", len(out))
83+
}
84+
if out["key3"] != "val3" {
85+
t.Errorf("key3 = %v, want %q", out["key3"], "val3")
86+
}
87+
}
88+
89+
func TestParseSimpleYAMLColonInValue(t *testing.T) {
90+
data := []byte("url: https://example.com\n")
91+
var out map[string]interface{}
92+
if err := parseSimpleYAML(data, &out); err != nil {
93+
t.Fatalf("unexpected error: %v", err)
94+
}
95+
if out["url"] != "https://example.com" {
96+
t.Errorf("url = %v, want %q", out["url"], "https://example.com")
97+
}
98+
}
99+
100+
func TestParseSimpleYAMLOnlyComments(t *testing.T) {
101+
data := []byte("# this is a comment\n# another comment\n")
102+
var out map[string]interface{}
103+
if err := parseSimpleYAML(data, &out); err != nil {
104+
t.Fatalf("unexpected error: %v", err)
105+
}
106+
if len(out) != 0 {
107+
t.Errorf("expected empty map for comment-only input, got %v", out)
108+
}
109+
}
110+
111+
func TestPackageInfoFields(t *testing.T) {
112+
info := PackageInfo{
113+
Name: "my-pkg",
114+
InstalledPath: "/path/to/.apm_modules/my-pkg",
115+
Ref: "v1.2.3",
116+
Commit: "deadbeef",
117+
Source: "https://github.com/owner/my-pkg",
118+
Files: []string{"SKILL.md", "apm.yml"},
119+
Versions: []string{"v1.0.0", "v1.2.3"},
120+
}
121+
if info.Name != "my-pkg" {
122+
t.Errorf("Name mismatch: %q", info.Name)
123+
}
124+
if len(info.Files) != 2 {
125+
t.Errorf("Files length: got %d, want 2", len(info.Files))
126+
}
127+
if info.Versions[1] != "v1.2.3" {
128+
t.Errorf("Versions[1]: got %q, want %q", info.Versions[1], "v1.2.3")
129+
}
130+
}

internal/core/experimental/experimental_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,51 @@ func TestDisplayName(t *testing.T) {
5252
}
5353
}
5454
}
55+
56+
func TestFlagsAreImmutable(t *testing.T) {
57+
flags1 := experimental.Flags()
58+
flags2 := experimental.Flags()
59+
if len(flags1) != len(flags2) {
60+
t.Errorf("Flags() returned different lengths on repeated calls: %d vs %d", len(flags1), len(flags2))
61+
}
62+
}
63+
64+
func TestFlagHasHint(t *testing.T) {
65+
flags := experimental.Flags()
66+
vv, ok := flags["verbose_version"]
67+
if !ok {
68+
t.Fatal("verbose_version not found")
69+
}
70+
if vv.Hint == "" {
71+
t.Error("verbose_version should have a non-empty Hint")
72+
}
73+
}
74+
75+
func TestFlagCopilotCoworkHasHint(t *testing.T) {
76+
flags := experimental.Flags()
77+
cc, ok := flags["copilot_cowork"]
78+
if !ok {
79+
t.Fatal("copilot_cowork not found")
80+
}
81+
if cc.Hint == "" {
82+
t.Error("copilot_cowork should have a non-empty Hint")
83+
}
84+
}
85+
86+
func TestDisplayNameMultipleUnderscores(t *testing.T) {
87+
cases := []struct {
88+
in string
89+
want string
90+
}{
91+
{"a_b_c_d", "a-b-c-d"},
92+
{"_leading", "-leading"},
93+
{"trailing_", "trailing-"},
94+
{"__double__", "--double--"},
95+
}
96+
for _, tc := range cases {
97+
got := experimental.DisplayName(tc.in)
98+
if got != tc.want {
99+
t.Errorf("DisplayName(%q) = %q, want %q", tc.in, got, tc.want)
100+
}
101+
}
102+
}

internal/deps/installedpkg/installedpkg_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,45 @@ func TestInstalledPackage_RegistryFields(t *testing.T) {
5252
t.Fatalf("RegistryPrefix mismatch")
5353
}
5454
}
55+
56+
func TestInstalledPackage_ZeroValue(t *testing.T) {
57+
var pkg installedpkg.InstalledPackage
58+
if pkg.Depth != 0 {
59+
t.Errorf("zero Depth should be 0, got %d", pkg.Depth)
60+
}
61+
if pkg.IsDev {
62+
t.Error("zero IsDev should be false")
63+
}
64+
if pkg.DepRefURL != "" {
65+
t.Errorf("zero DepRefURL should be empty, got %q", pkg.DepRefURL)
66+
}
67+
}
68+
69+
func TestInstalledPackage_DepthLevels(t *testing.T) {
70+
for _, depth := range []int{0, 1, 2, 5, 10} {
71+
pkg := installedpkg.InstalledPackage{Depth: depth}
72+
if pkg.Depth != depth {
73+
t.Errorf("Depth: got %d, want %d", pkg.Depth, depth)
74+
}
75+
}
76+
}
77+
78+
func TestInstalledPackage_ResolvedBy(t *testing.T) {
79+
cases := []string{"direct", "transitive", "dev", "peer"}
80+
for _, by := range cases {
81+
pkg := installedpkg.InstalledPackage{ResolvedBy: by}
82+
if pkg.ResolvedBy != by {
83+
t.Errorf("ResolvedBy: got %q, want %q", pkg.ResolvedBy, by)
84+
}
85+
}
86+
}
87+
88+
func TestInstalledPackage_CommitFormats(t *testing.T) {
89+
commits := []string{"abc1234", "deadbeef12345678", "0000000"}
90+
for _, c := range commits {
91+
pkg := installedpkg.InstalledPackage{ResolvedCommit: c}
92+
if pkg.ResolvedCommit != c {
93+
t.Errorf("ResolvedCommit: got %q, want %q", pkg.ResolvedCommit, c)
94+
}
95+
}
96+
}

internal/install/mcp/mcpconflicts/mcpconflicts_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,53 @@ func TestPositionalPackagesMixedWithMCP_Fails(t *testing.T) {
5656
func TestValidMCPWithStdio(t *testing.T) {
5757
ok(t, mcpconflicts.ConflictConfig{HasMCPName: true, MCPName: "myserver", Transport: "stdio"})
5858
}
59+
60+
func TestValidMCPWithURL(t *testing.T) {
61+
ok(t, mcpconflicts.ConflictConfig{HasMCPName: true, MCPName: "srv", URL: "https://mcp.example.com"})
62+
}
63+
64+
func TestMCPWithEnv(t *testing.T) {
65+
ok(t, mcpconflicts.ConflictConfig{
66+
HasMCPName: true,
67+
MCPName: "srv",
68+
Env: map[string]string{"TOKEN": "abc"},
69+
})
70+
}
71+
72+
func TestNoMCPName_WithEnv_Fails(t *testing.T) {
73+
fail(t, mcpconflicts.ConflictConfig{
74+
HasMCPName: false,
75+
Env: map[string]string{"X": "1"},
76+
}, "--env requires --mcp")
77+
}
78+
79+
func TestMCPWithHeader(t *testing.T) {
80+
ok(t, mcpconflicts.ConflictConfig{
81+
HasMCPName: true,
82+
MCPName: "srv",
83+
URL: "https://mcp.example.com",
84+
Headers: map[string]string{"Authorization": "Bearer token"},
85+
})
86+
}
87+
88+
func TestConflictConfigZeroValue(t *testing.T) {
89+
var cfg mcpconflicts.ConflictConfig
90+
if cfg.HasMCPName {
91+
t.Error("HasMCPName default should be false")
92+
}
93+
if cfg.Global {
94+
t.Error("Global default should be false")
95+
}
96+
}
97+
98+
func TestValidationErrorImplementsError(t *testing.T) {
99+
cfg := mcpconflicts.ConflictConfig{HasMCPName: false, Transport: "stdio"}
100+
err := mcpconflicts.ValidateMCPConflicts(cfg)
101+
if err == nil {
102+
t.Fatal("expected error")
103+
}
104+
msg := err.Error()
105+
if msg == "" {
106+
t.Error("error message should not be empty")
107+
}
108+
}

internal/install/request/request_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,55 @@ func TestInstallRequestFields(t *testing.T) {
5656
t.Errorf("ProtocolPref: got %q, want %q", r.ProtocolPref, "https")
5757
}
5858
}
59+
60+
func TestInstallRequestZeroValue(t *testing.T) {
61+
var r request.InstallRequest
62+
if r.ParallelDownloads != 0 {
63+
t.Errorf("zero ParallelDownloads: got %d, want 0", r.ParallelDownloads)
64+
}
65+
if r.Force {
66+
t.Error("zero Force should be false")
67+
}
68+
}
69+
70+
func TestDefaultInstallRequest_AllowInsecureFalse(t *testing.T) {
71+
r := request.DefaultInstallRequest()
72+
if r.AllowInsecure {
73+
t.Error("AllowInsecure default should be false")
74+
}
75+
if len(r.AllowInsecureHosts) != 0 {
76+
t.Errorf("AllowInsecureHosts should be empty, got %v", r.AllowInsecureHosts)
77+
}
78+
}
79+
80+
func TestDefaultInstallRequest_NoSkillSubset(t *testing.T) {
81+
r := request.DefaultInstallRequest()
82+
if len(r.SkillSubset) != 0 {
83+
t.Errorf("SkillSubset should be empty, got %v", r.SkillSubset)
84+
}
85+
if r.SkillSubsetFromCLI {
86+
t.Error("SkillSubsetFromCLI should default to false")
87+
}
88+
}
89+
90+
func TestDefaultInstallRequest_NotFrozen(t *testing.T) {
91+
r := request.DefaultInstallRequest()
92+
if r.Frozen {
93+
t.Error("Frozen should default to false")
94+
}
95+
if r.LegacySkillPaths {
96+
t.Error("LegacySkillPaths should default to false")
97+
}
98+
}
99+
100+
func TestInstallRequest_OnlyPackages(t *testing.T) {
101+
r := request.InstallRequest{
102+
OnlyPackages: []string{"alpha", "beta", "gamma"},
103+
}
104+
if len(r.OnlyPackages) != 3 {
105+
t.Errorf("OnlyPackages: got %d, want 3", len(r.OnlyPackages))
106+
}
107+
if r.OnlyPackages[2] != "gamma" {
108+
t.Errorf("OnlyPackages[2]: got %q, want %q", r.OnlyPackages[2], "gamma")
109+
}
110+
}

0 commit comments

Comments
 (0)