diff options
| author | Shulhan <ms@kilabit.info> | 2018-05-26 23:58:00 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2018-05-27 02:34:34 +0700 |
| commit | 519c842c438b4a7db3e716b323aa4f821aac401d (patch) | |
| tree | e16916dd8ef66274acffd065b14f541ae8ac2e78 | |
| parent | 0f902e44e4753fd008582ce3ce9c313da94b8882 (diff) | |
| download | beku-519c842c438b4a7db3e716b323aa4f821aac401d.tar.xz | |
[test] package: check for nil before comparing with expected value
| -rw-r--r-- | beku_test.go | 7 | ||||
| -rw-r--r-- | package_test.go | 12 |
2 files changed, 16 insertions, 3 deletions
diff --git a/beku_test.go b/beku_test.go index e41640e..2660aad 100644 --- a/beku_test.go +++ b/beku_test.go @@ -74,6 +74,13 @@ func testResetOutput(t *testing.T, truncate bool) { } } +func testPrintOutput(t *testing.T) { + testResetOutput(t, false) + stdout, stderr := testGetOutput(t) + t.Log(">>> stdout:\n", stdout) + t.Log(">>> stderr:\n", stderr) +} + func TestMain(m *testing.M) { orgGOPATH := build.Default.GOPATH diff --git a/package_test.go b/package_test.go index d1cf880..815953b 100644 --- a/package_test.go +++ b/package_test.go @@ -73,7 +73,12 @@ func testPackageInstall(t *testing.T) { for _, c := range cases { t.Log(c.desc) + testResetOutput(t, true) + err := c.pkg.Install() + + testPrintOutput(t) + if err != nil { test.Assert(t, "err", c.expErr, err.Error(), true) continue @@ -730,9 +735,10 @@ func testPackageGoClean(t *testing.T) { if len(c.pkgBin) > 0 { _, err = os.Stat(c.pkgBin) - exp := fmt.Sprintf(c.expBinErr, c.pkgBin) - - test.Assert(t, "pkgBin", exp, err.Error(), true) + if err != nil { + exp := fmt.Sprintf(c.expBinErr, c.pkgBin) + test.Assert(t, "pkgBin", exp, err.Error(), true) + } } } } |
