-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit_tests.bats
executable file
·67 lines (54 loc) · 1.72 KB
/
unit_tests.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
#!/usr/bin/env bats
source ./compare_semantic_versions
@test 'Succeeds when new major version is greater then the old major version' {
echo compare_semantic_version
run compare_semantic_version 1.1.1 2.1.1
[ $status = 0 ]
}
@test 'Fails when new major version is equal to the old major version' {
run compare_semantic_version 1.2.1 1.2.1
[ $status = 1 ]
}
@test 'Fails when new major version less then the old major version' {
run compare_semantic_version 1.2.1 1.1.1
[ $status = 1 ]
}
# Minor Version tests
@test 'Succeeds when new minor version is greater then the old minor version' {
run compare_semantic_version 1.1.1 1.2.1
[ $status = 0 ]
}
@test 'Fails when new minor version is equal to the old minor version' {
run compare_semantic_version 1.2.1 1.2.1
[ $status = 1 ]
}
@test 'Fails when new minor version less then the old minor version' {
run compare_semantic_version 1.2.1 1.1.1
[ $status = 1 ]
}
# Patch Version Tests
@test 'Succeeds when new patch version is greater then the old patch version' {
run compare_semantic_version 1.1.1 1.1.2
[ $status = 0 ]
}
@test 'Fails when new patch version is equal to the old patch version' {
run compare_semantic_version 1.1.2 1.1.2
[ $status = 1 ]
}
@test 'Fails when new patch version less then the old patch version' {
run compare_semantic_version 1.1.2 1.1.1
[ $status = 1 ]
}
# With variable depth
@test 'Returns false because ignores path version' {
run compare_semantic_version 1.1.1 1.1.2 2
[ $status = 1 ]
}
@test 'Returns true when minor version is higher and path version is ignored' {
run compare_semantic_version 1.1.1 1.2.1 2
[ $status = 0 ]
}
@test 'Returns false because ignores minor version' {
run compare_semantic_version 1.1.2 1.2.3 1
[ $status = 1 ]
}