gf/os/gproc/gproc_z_unit_test.go
2021-12-14 21:01:36 +08:00

30 lines
685 B
Go

// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
// go test *.go -bench=".*" -benchmem
package gproc_test
import (
"testing"
"github.com/gogf/gf/v2/os/gproc"
"github.com/gogf/gf/v2/test/gtest"
)
func Test_ShellExec(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
s, err := gproc.ShellExec(`echo 123`)
t.AssertNil(err)
t.Assert(s, "123\n")
})
// error
gtest.C(t, func(t *gtest.T) {
_, err := gproc.ShellExec(`NoneExistCommandCall`)
t.AssertNE(err, nil)
})
}