Skip to content

Commit

Permalink
Update internal/info test and add new case for coverage (#2003)
Browse files Browse the repository at this point in the history
* ✅ Update internal/info test and add new case for coverage

Signed-off-by: vankichi <[email protected]>

* ✅ use map for comparing got and want instead of raw text

Signed-off-by: vankichi <[email protected]>

* ♻️ add constant value about cgoEnabled  for internal/info

Signed-off-by: vankichi <[email protected]>

---------

Signed-off-by: vankichi <[email protected]>
  • Loading branch information
vankichi authored Apr 11, 2023
1 parent c39b23a commit 88a417c
Show file tree
Hide file tree
Showing 2 changed files with 232 additions and 77 deletions.
21 changes: 12 additions & 9 deletions internal/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@ var (
)

const (
goSrc = "go/src/"
goSrcLen = len(goSrc)
goMod = "go/pkg/mod/"
goModLen = len(goMod)
goSrc = "go/src/"
goSrcLen = len(goSrc)
goMod = "go/pkg/mod/"
goModLen = len(goMod)
cgoTrue = "true"
cgoFalse = "false"
cgoUnknown = "unknown"
)

// Init initializes Detail object only once.
Expand Down Expand Up @@ -351,12 +354,12 @@ func (i *info) prepare() {
i.detail.CGOEnabled = CGOEnabled
}
switch i.detail.CGOEnabled {
case "0", "false":
i.detail.CGOEnabled = "false"
case "1", "true":
i.detail.CGOEnabled = "true"
case "0", cgoFalse:
i.detail.CGOEnabled = cgoFalse
case "1", cgoTrue:
i.detail.CGOEnabled = cgoTrue
default:
i.detail.CGOEnabled = "unknown"
i.detail.CGOEnabled = cgoUnknown
}
if len(i.detail.NGTVersion) == 0 && len(NGTVersion) != 0 {
i.detail.NGTVersion = NGTVersion
Expand Down
Loading

0 comments on commit 88a417c

Please sign in to comment.