Skip to content

Commit 79313a0

Browse files
authored
Merge pull request #26 from mpyw/fix/revert-internal-tests-to-internal-package
fix: revert internal tests to internal package
2 parents 66b7333 + d9d415f commit 79313a0

File tree

4 files changed

+22
-32
lines changed

4 files changed

+22
-32
lines changed

internal/directive/carrier/carrier_test.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
package carrier_test
1+
package carrier
22

33
import (
44
"testing"
5-
6-
"github.com/mpyw/goroutinectx/internal/directive/carrier"
75
)
86

97
func TestMatchPkg(t *testing.T) {
@@ -69,7 +67,7 @@ func TestMatchPkg(t *testing.T) {
6967
t.Run(tt.name, func(t *testing.T) {
7068
t.Parallel()
7169

72-
if got := carrier.MatchPkg(tt.pkgPath, tt.targetPkg); got != tt.want {
70+
if got := matchPkg(tt.pkgPath, tt.targetPkg); got != tt.want {
7371
t.Errorf("matchPkg(%q, %q) = %v, want %v", tt.pkgPath, tt.targetPkg, got, tt.want)
7472
}
7573
})
@@ -82,7 +80,7 @@ func TestParse(t *testing.T) {
8280
tests := []struct {
8381
name string
8482
input string
85-
want []carrier.Carrier
83+
want []Carrier
8684
}{
8785
{
8886
name: "empty string",
@@ -92,35 +90,35 @@ func TestParse(t *testing.T) {
9290
{
9391
name: "single carrier",
9492
input: "github.com/example/pkg.Type",
95-
want: []carrier.Carrier{{PkgPath: "github.com/example/pkg", TypeName: "Type"}},
93+
want: []Carrier{{PkgPath: "github.com/example/pkg", TypeName: "Type"}},
9694
},
9795
{
9896
name: "multiple carriers",
9997
input: "pkg1.Type1,pkg2.Type2",
100-
want: []carrier.Carrier{{PkgPath: "pkg1", TypeName: "Type1"}, {PkgPath: "pkg2", TypeName: "Type2"}},
98+
want: []Carrier{{PkgPath: "pkg1", TypeName: "Type1"}, {PkgPath: "pkg2", TypeName: "Type2"}},
10199
},
102100
{
103101
name: "with spaces",
104102
input: " pkg1.Type1 , pkg2.Type2 ",
105-
want: []carrier.Carrier{{PkgPath: "pkg1", TypeName: "Type1"}, {PkgPath: "pkg2", TypeName: "Type2"}},
103+
want: []Carrier{{PkgPath: "pkg1", TypeName: "Type1"}, {PkgPath: "pkg2", TypeName: "Type2"}},
106104
},
107105
{
108106
name: "invalid format - no dot",
109107
input: "invalid",
110-
want: []carrier.Carrier{},
108+
want: []Carrier{},
111109
},
112110
{
113111
name: "empty parts are skipped",
114112
input: "pkg.Type,,other.Type",
115-
want: []carrier.Carrier{{PkgPath: "pkg", TypeName: "Type"}, {PkgPath: "other", TypeName: "Type"}},
113+
want: []Carrier{{PkgPath: "pkg", TypeName: "Type"}, {PkgPath: "other", TypeName: "Type"}},
116114
},
117115
}
118116

119117
for _, tt := range tests {
120118
t.Run(tt.name, func(t *testing.T) {
121119
t.Parallel()
122120

123-
got := carrier.Parse(tt.input)
121+
got := Parse(tt.input)
124122
if len(got) != len(tt.want) {
125123
t.Errorf("Parse(%q) returned %d carriers, want %d", tt.input, len(got), len(tt.want))
126124
return

internal/directive/carrier/export_test.go

Lines changed: 0 additions & 3 deletions
This file was deleted.

internal/probe/composite_test.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
package probe_test
1+
package probe
22

33
import (
44
"go/ast"
55
"go/token"
66
"testing"
7-
8-
"github.com/mpyw/goroutinectx/internal/probe"
97
)
108

119
func TestFuncLitOfLiteralKey(t *testing.T) {
@@ -29,7 +27,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
2927
}
3028
lit := &ast.BasicLit{Kind: token.INT, Value: "1"}
3129

32-
result := probe.FuncLitOfLiteralKey(compLit, lit)
30+
result := funcLitOfLiteralKey(compLit, lit)
3331
if result != fl1 {
3432
t.Errorf("expected fl1, got %v", result)
3533
}
@@ -44,7 +42,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
4442
}
4543
lit := &ast.BasicLit{Kind: token.INT, Value: "0"}
4644

47-
result := probe.FuncLitOfLiteralKey(compLit, lit)
45+
result := funcLitOfLiteralKey(compLit, lit)
4846
if result != fl0 {
4947
t.Errorf("expected fl0, got %v", result)
5048
}
@@ -58,7 +56,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
5856
}
5957
lit := &ast.BasicLit{Kind: token.INT, Value: "-1"}
6058

61-
result := probe.FuncLitOfLiteralKey(compLit, lit)
59+
result := funcLitOfLiteralKey(compLit, lit)
6260
if result != nil {
6361
t.Errorf("expected nil for negative index, got %v", result)
6462
}
@@ -72,7 +70,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
7270
}
7371
lit := &ast.BasicLit{Kind: token.INT, Value: "5"}
7472

75-
result := probe.FuncLitOfLiteralKey(compLit, lit)
73+
result := funcLitOfLiteralKey(compLit, lit)
7674
if result != nil {
7775
t.Errorf("expected nil for out of range index, got %v", result)
7876
}
@@ -86,7 +84,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
8684
}
8785
lit := &ast.BasicLit{Kind: token.INT, Value: "abc"}
8886

89-
result := probe.FuncLitOfLiteralKey(compLit, lit)
87+
result := funcLitOfLiteralKey(compLit, lit)
9088
if result != nil {
9189
t.Errorf("expected nil for invalid int format, got %v", result)
9290
}
@@ -100,7 +98,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
10098
}
10199
lit := &ast.BasicLit{Kind: token.INT, Value: "0"}
102100

103-
result := probe.FuncLitOfLiteralKey(compLit, lit)
101+
result := funcLitOfLiteralKey(compLit, lit)
104102
if result != nil {
105103
t.Errorf("expected nil when element is not FuncLit, got %v", result)
106104
}
@@ -120,7 +118,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
120118
}
121119
lit := &ast.BasicLit{Kind: token.STRING, Value: `"mykey"`}
122120

123-
result := probe.FuncLitOfLiteralKey(compLit, lit)
121+
result := funcLitOfLiteralKey(compLit, lit)
124122
if result != fl {
125123
t.Errorf("expected fl, got %v", result)
126124
}
@@ -139,7 +137,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
139137
}
140138
lit := &ast.BasicLit{Kind: token.STRING, Value: `"mykey"`}
141139

142-
result := probe.FuncLitOfLiteralKey(compLit, lit)
140+
result := funcLitOfLiteralKey(compLit, lit)
143141
if result != nil {
144142
t.Errorf("expected nil when key not found, got %v", result)
145143
}
@@ -158,7 +156,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
158156
}
159157
lit := &ast.BasicLit{Kind: token.STRING, Value: `"mykey"`}
160158

161-
result := probe.FuncLitOfLiteralKey(compLit, lit)
159+
result := funcLitOfLiteralKey(compLit, lit)
162160
if result != nil {
163161
t.Errorf("expected nil when value is not FuncLit, got %v", result)
164162
}
@@ -172,7 +170,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
172170
}
173171
lit := &ast.BasicLit{Kind: token.STRING, Value: `"mykey"`}
174172

175-
result := probe.FuncLitOfLiteralKey(compLit, lit)
173+
result := funcLitOfLiteralKey(compLit, lit)
176174
if result != nil {
177175
t.Errorf("expected nil when element is not KeyValueExpr, got %v", result)
178176
}
@@ -191,7 +189,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
191189
}
192190
lit := &ast.BasicLit{Kind: token.STRING, Value: `"mykey"`}
193191

194-
result := probe.FuncLitOfLiteralKey(compLit, lit)
192+
result := funcLitOfLiteralKey(compLit, lit)
195193
if result != nil {
196194
t.Errorf("expected nil when key is not BasicLit, got %v", result)
197195
}
@@ -205,7 +203,7 @@ func TestFuncLitOfLiteralKey(t *testing.T) {
205203
}
206204
lit := &ast.BasicLit{Kind: token.FLOAT, Value: "1.5"}
207205

208-
result := probe.FuncLitOfLiteralKey(compLit, lit)
206+
result := funcLitOfLiteralKey(compLit, lit)
209207
if result != nil {
210208
t.Errorf("expected nil for unsupported token kind, got %v", result)
211209
}

internal/probe/export_test.go

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)