1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
diff --git a/gomodinit_test.go b/gomodinit_test.go
index bb5bb02185fb0e7a76850999617d2e029f753fe6..c62464d70c67a202a08333d6c858ffd237710c87 100644
--- a/gomodinit_test.go
+++ b/gomodinit_test.go
@@ -14,9 +14,10 @@ func TestModule(t *testing.T) {
tmp := t.TempDir()
tt := []struct {
- Name string
- Path string
- Expected string
+ Name string
+ Path string
+ Expected string
+ GoModInitFile string
}{
{
Name: "gitea",
@@ -33,6 +34,12 @@ Name: "no_uri",
Path: "giteacom/user3/repo",
Expected: "%s/giteacom/user3/repo",
},
+ {
+ Name: ".gomodinit",
+ Path: "gitea.com/user3/repo",
+ Expected: "go.gitea.com/user3/repo",
+ GoModInitFile: "go.gitea.com",
+ },
}
for _, tc := range tt {
@@ -43,6 +50,14 @@ dir := filepath.Join(tmp, tc.Path)
err := os.MkdirAll(dir, os.ModePerm)
assert.NoErr(err) // Should create temp dir
+
+ if tc.GoModInitFile != "" {
+ fi, err := os.Create(filepath.Join(tmp, "gitea.com", ".gomodinit"))
+ assert.NoErr(err) // Should create .gomodinit file
+ _, err = fi.WriteString(tc.GoModInitFile)
+ assert.NoErr(err) // Should write to .gomodinit file
+ assert.NoErr(fi.Close()) // Should close .gomodinit file
+ }
err = os.Chdir(dir)
assert.NoErr(err) // Should chdir to temp dir
|