Skip to content

Commit

Permalink
modload: test mod.DepMods
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Feb 10, 2024
1 parent 8412df4 commit 742fb3b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 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,26 @@ 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 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 742fb3b

Please sign in to comment.