-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathExecCommandExecuteUnixTests.fs
More file actions
95 lines (83 loc) · 2.02 KB
/
ExecCommandExecuteUnixTests.fs
File metadata and controls
95 lines (83 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
module Fli.Tests.ExecContext.ExecCommandExecuteLinuxTests
open NUnit.Framework
open FsUnit
open Fli
open System
open System.Text
[<Test>]
[<Platform("Linux,Unix,MacOsX")>]
let ``Hello World with executing program`` () =
cli {
Exec "bash"
Arguments "-c \"echo Hello World!\""
}
|> Command.execute
|> Output.toText
|> should equal "Hello World!"
[<Test>]
[<Platform("Linux,Unix,MacOsX")>]
let ``Get process Id`` () =
cli {
Exec "bash"
Arguments "-c \"echo Test\""
}
|> Command.execute
|> Output.toId
|> should not' (equal 0)
[<Test>]
[<Platform("Linux,Unix,MacOsX")>]
let ``print text with Input with executing program`` () =
cli {
Exec "bash"
Arguments "-c \"echo Test\""
Input "echo Hello World!"
WorkingDirectory @"/etc/"
}
|> Command.execute
|> Output.toText
|> should equal "Test"
[<Test>]
[<Platform("Linux,Unix,MacOsX")>]
let ``Get output in StringBuilder`` () =
let sb = StringBuilder()
cli {
Exec "bash"
Arguments "-c \"echo Test\""
Output sb
}
|> Command.execute
|> ignore
sb.ToString() |> should equal "Test\n"
[<Test>]
[<Platform("Linux,Unix,MacOsX")>]
let ``Call custom function in output`` () =
let testFunc (test: string) (s: string) = s |> should equal test
cli {
Exec "bash"
Arguments "-c \"echo Test\""
Output(testFunc "Test\n")
}
|> Command.execute
|> ignore
[<Test>]
[<Platform("Linux,Unix,MacOsX")>]
let ``Hello World with executing program async`` () =
async {
let! output =
cli {
Exec "bash"
Arguments "-c \"echo Hello World!\""
}
|> Command.executeAsync
output |> Output.toText |> should equal "Hello World!"
}
[<Test>]
[<Platform("Linux,Unix,MacOsX")>]
let ``Passing data to a progrma on stdin`` () =
cli {
Exec "cat"
Input "Test"
}
|> Command.execute
|> Output.toText
|> should equal "Test"