Skip to content

Commit

Permalink
Merge pull request #56 from xushiwei/req
Browse files Browse the repository at this point in the history
modload: test mod.DepMods
  • Loading branch information
xushiwei committed Feb 10, 2024
2 parents 8412df4 + c053435 commit 03f041a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions modload/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package modload

import (
"encoding/json"
"runtime"
"testing"

Expand Down Expand Up @@ -105,4 +106,28 @@ require (
` {
t.Fatal("AddRequire:", v)
}

mod.AddReplace("github.com/goplus/yap", "v0.7.2", "../", "")
if b, err := mod.File.Format(); err != nil {
t.Fatal("AddReplace & Format:", err)
} else if v := string(b); v != `module github.com/foo/bar
go 1.18
require (
github.com/goplus/yap v0.7.2 //gop:class
github.com/qiniu/x v0.1.0
)
replace github.com/goplus/yap v0.7.2 => ../
` {
t.Fatal("AddReplace:", v)
}

b, _ := json.Marshal(mod.DepMods())
if runtime.GOOS != "windows" {
if v := string(b); v != `{"github.com/goplus/yap":{"Path":"/foo"},"github.com/qiniu/x":{"Path":"github.com/qiniu/x","Version":"v0.1.0"}}` {
t.Fatal("mod.DepMods:", v)
}
}
}

0 comments on commit 03f041a

Please sign in to comment.