-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.sh.bats
executable file
·123 lines (94 loc) · 2.21 KB
/
functions.sh.bats
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bats
# testing functions.sh
. /home/pi/src/functions.sh
@test "PrintLogMessage()" {
declare -f PrintLogMessage
}
@test "SwitchAirOn()" {
declare -f SwitchAirOn
}
@test "SwitchAirOff()" {
declare -f SwitchAirOff
}
@test "SwitchPumpInputOn()" {
declare -f SwitchPumpInputOn
}
@test "SwitchPumpInputOff()" {
declare -f SwitchPumpInputOff
}
@test "SwitchPumpOutputOn()" {
declare -f SwitchPumpOutputOn
}
@test "SwitchPumpOutputOff()" {
declare -f SwitchPumpOutputOff
}
@test "SwitchUVOn()" {
declare -f SwitchUVOn
}
@test "SwitchUVOff()" {
declare -f SwitchUVOff
}
@test "SwitchLEDOn()" {
declare -f SwitchLEDOn
}
@test "SwitchLEDOff()" {
declare -f SwitchLEDOff
}
@test "PushSensorData()" {
declare -f PushSensorData
}
@test "PushSensorData - not 5 parameter" {
run PushSensorData 1 2 3 4
[ "$status" -eq 1 ]
[ "$output" == "parameter error" ]
run PushSensorData 1 2 3 4 5 6
[ "$status" -eq 1 ]
[ "$output" == "parameter error" ]
}
@test "PushSensorDHT22()" {
declare -f PushSensorDHT22
}
@test "PushSensorDHT22 - not 3 parameter" {
run PushSensorDHT22 1 2
[ "$status" -eq 1 ]
[ "$output" == "parameter error" ]
run PushSensorDHT22 1 2 3 4
[ "$status" -eq 1 ]
[ "$output" == "parameter error" ]
}
@test "PullAction()" {
declare -f PullAction
}
@test "GetValuePercentWater()" {
declare -f GetValuePercentWater
}
@test "GetValuePercentUV()" {
declare -f GetValuePercentUV
}
@test "GetValueSecondsWaterFromPercent()" {
declare -f GetValueSecondsWaterFromPercent
}
@test "GetValueSecondsWaterFromPercent parameter 'percent' < 0" {
run GetValueSecondsWaterFromPercent -1
[ "$status" -eq 1 ]
[ "$output" == "parameter error" ]
}
@test "GetValueSecondsWaterFromPercent parameter 'percent' > 100" {
run GetValueSecondsWaterFromPercent 101
[ "$status" -eq 1 ]
[ "$output" == "parameter error" ]
}
@test "GetValueSecondsWaterFromPercent: 0 10 50 100" {
run GetValueSecondsWaterFromPercent 0
[ "$status" -eq 0 ]
[ "$output" -eq 0 ]
run GetValueSecondsWaterFromPercent 10
[ "$status" -eq 0 ]
[ "$output" == ".10" ]
run GetValueSecondsWaterFromPercent 50
[ "$status" -eq 0 ]
[ "$output" == ".50" ]
run GetValueSecondsWaterFromPercent 100
[ "$status" -eq 0 ]
[ "$output" == "1.00" ]
}