github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/management/functions_test.go (about) 1 package management_test 2 3 import ( 4 "runtime" 5 "testing" 6 7 _ "github.com/lmorg/murex/builtins" 8 "github.com/lmorg/murex/test" 9 ) 10 11 func TestExitNum(t *testing.T) { 12 tests := []test.MurexTest{ 13 { 14 Block: `exitnum`, 15 Stdout: "0\n", 16 }, 17 { 18 Block: `err bob; exitnum`, 19 Stdout: "1\n", 20 Stderr: "bob\n", 21 }, 22 } 23 24 test.RunMurexTests(tests, t) 25 } 26 27 func TestBuiltinExists(t *testing.T) { 28 tests := []test.MurexTest{ 29 { 30 Block: `bexists: bob`, 31 Stdout: `{"Installed":null,"Missing":["bob"]}` + "\n", 32 ExitNum: 1, 33 }, 34 { 35 Block: `bexists: cd`, 36 Stdout: `{"Installed":["cd"],"Missing":null}` + "\n", 37 }, 38 { 39 Block: `bexists: cd bexists`, 40 Stdout: `{"Installed":["cd","bexists"],"Missing":null}` + "\n", 41 }, 42 { 43 Block: `bexists: bob1 bob2`, 44 Stdout: `{"Installed":null,"Missing":["bob1","bob2"]}` + "\n", 45 ExitNum: 2, 46 }, 47 { 48 Block: `bexists: cd bob1 bexists bob2`, 49 Stdout: `{"Installed":["cd","bexists"],"Missing":["bob1","bob2"]}` + "\n", 50 ExitNum: 2, 51 }, 52 } 53 54 test.RunMurexTests(tests, t) 55 } 56 57 func TestBuiltinExistsErrors(t *testing.T) { 58 tests := []test.MurexTest{ 59 { 60 Block: `bexists`, 61 Stderr: `missing parameters`, 62 ExitNum: 1, 63 }, 64 } 65 66 test.RunMurexTestsRx(tests, t) 67 } 68 69 func TestOs(t *testing.T) { 70 tests := []test.MurexTest{ 71 { 72 Block: `os`, 73 Stdout: runtime.GOOS, 74 }, 75 { 76 Block: `os: bob`, 77 Stdout: "false", 78 ExitNum: 1, 79 }, 80 { 81 Block: `os: windows`, 82 Stdout: "false", 83 ExitNum: 1, 84 }, 85 { 86 Block: `os: ` + runtime.GOOS, 87 Stdout: "true", 88 }, 89 } 90 91 test.RunMurexTests(tests, t) 92 }