From e996d4c9459e228f6d1b9fe717957fc44d794e41 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Fri, 30 Dec 2022 14:14:37 +0800 Subject: [PATCH] test: add examples for system package --- system/os_example_test.go | 72 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 system/os_example_test.go diff --git a/system/os_example_test.go b/system/os_example_test.go new file mode 100644 index 0000000..26da4df --- /dev/null +++ b/system/os_example_test.go @@ -0,0 +1,72 @@ +package system + +import "fmt" + +func ExampleSetOsEnv() { + ok := SetOsEnv("foo", "abc") + result := GetOsEnv("foo") + + fmt.Println(ok) + fmt.Println(result) + // Output: + // + // abc +} + +func ExampleGetOsEnv() { + ok := SetOsEnv("foo", "abc") + result := GetOsEnv("foo") + + fmt.Println(ok) + fmt.Println(result) + // Output: + // + // abc +} + +func ExampleRemoveOsEnv() { + ok1 := SetOsEnv("foo", "abc") + result1 := GetOsEnv("foo") + + ok2 := RemoveOsEnv("foo") + result2 := GetOsEnv("foo") + + fmt.Println(ok1) + fmt.Println(ok2) + fmt.Println(result1) + fmt.Println(result2) + + // Output: + // + // + // abc + // +} + +func ExampleCompareOsEnv() { + SetOsEnv("foo", "abc") + result1 := CompareOsEnv("foo", "abc") + + fmt.Println(result1) + // Output: + // true +} + +func ExampleExecCommand() { + _, stderr, err := ExecCommand("ls") + // fmt.Println(stdout) + fmt.Println(stderr) + fmt.Println(err) + + // Output: + // + // +} + +func ExampleGetOsBits() { + osBits := GetOsBits() + + fmt.Println(osBits) + // Output: + // 64 +}