@@ -9,89 +9,89 @@ import (
9
9
10
10
var _ = Describe ("IP" , func () {
11
11
Context ("v4" , func () {
12
- Describe ("ParseIP" , func () {
13
- It ("returns an IP object that represents IP from string" , func () {
14
- ip , err := bosh .ParseIP ("10.0.16.255" )
15
- Expect (err ).NotTo (HaveOccurred ())
16
- Expect (ip .String ()).To (Equal ("10.0.16.255" ))
17
- })
18
-
19
- Context ("failure cases" , func () {
20
- It ("returns an error if it cannot parse ip" , func () {
21
- _ , err := bosh .ParseIP ("not valid" )
22
- Expect (err ).To (MatchError (ContainSubstring ("unable to parse IP" )))
12
+ Describe ("ParseIP" , func () {
13
+ It ("returns an IP object that represents IP from string" , func () {
14
+ ip , err := bosh .ParseIP ("10.0.16.255" )
15
+ Expect (err ).NotTo (HaveOccurred ())
16
+ Expect (ip .String ()).To (Equal ("10.0.16.255" ))
23
17
})
24
18
25
- It ("returns an error if ip parts are not digits" , func () {
26
- _ , err := bosh .ParseIP ("x.x.x.x" )
27
- Expect (err ).To (MatchError (ContainSubstring ("unexpected character" )))
28
- })
19
+ Context ("failure cases" , func () {
20
+ It ("returns an error if it cannot parse ip" , func () {
21
+ _ , err := bosh .ParseIP ("not valid" )
22
+ Expect (err ).To (MatchError (ContainSubstring ("unable to parse IP" )))
23
+ })
29
24
30
- It ("returns an error if ip parts are out of the allowed range" , func () {
31
- _ , err := bosh .ParseIP ("999.999.999.999" )
32
- Expect (err ).To (MatchError (ContainSubstring ("IPv4 field has value >255" )))
33
- })
25
+ It ("returns an error if ip parts are not digits" , func () {
26
+ _ , err := bosh .ParseIP ("x.x.x.x" )
27
+ Expect (err ).To (MatchError (ContainSubstring ("unexpected character" )))
28
+ })
29
+
30
+ It ("returns an error if ip parts are out of the allowed range" , func () {
31
+ _ , err := bosh .ParseIP ("999.999.999.999" )
32
+ Expect (err ).To (MatchError (ContainSubstring ("IPv4 field has value >255" )))
33
+ })
34
34
35
- It ("returns an error if ip has too many parts" , func () {
36
- _ , err := bosh .ParseIP ("1.1.1.1.1.1.1" )
37
- Expect (err ).To (MatchError (ContainSubstring ("IPv4 address too long" )))
35
+ It ("returns an error if ip has too many parts" , func () {
36
+ _ , err := bosh .ParseIP ("1.1.1.1.1.1.1" )
37
+ Expect (err ).To (MatchError (ContainSubstring ("IPv4 address too long" )))
38
+ })
38
39
})
39
40
})
40
- })
41
41
42
- Describe ("Add" , func () {
43
- It ("returns an IP object that represents IP offsetted by 1" , func () {
44
- ip , err := bosh .ParseIP ("10.0.16.1" )
45
- ip = ip .Add (1 )
46
- Expect (err ).NotTo (HaveOccurred ())
47
- Expect (ip .String ()).To (Equal ("10.0.16.2" ))
42
+ Describe ("Add" , func () {
43
+ It ("returns an IP object that represents IP offsetted by 1" , func () {
44
+ ip , err := bosh .ParseIP ("10.0.16.1" )
45
+ ip = ip .Add (1 )
46
+ Expect (err ).NotTo (HaveOccurred ())
47
+ Expect (ip .String ()).To (Equal ("10.0.16.2" ))
48
+ })
48
49
})
49
- })
50
50
51
- Describe ("Subtract" , func () {
52
- It ("returns an IP object that represents IP offsetted by -1" , func () {
53
- ip , err := bosh .ParseIP ("10.0.16.2" )
54
- ip = ip .Subtract (1 )
55
- Expect (err ).NotTo (HaveOccurred ())
56
- Expect (ip .String ()).To (Equal ("10.0.16.1" ))
51
+ Describe ("Subtract" , func () {
52
+ It ("returns an IP object that represents IP offsetted by -1" , func () {
53
+ ip , err := bosh .ParseIP ("10.0.16.2" )
54
+ ip = ip .Subtract (1 )
55
+ Expect (err ).NotTo (HaveOccurred ())
56
+ Expect (ip .String ()).To (Equal ("10.0.16.1" ))
57
+ })
57
58
})
58
- })
59
59
60
- Describe ("String" , func () {
61
- It ("returns a string representation of IP object" , func () {
62
- ip , err := bosh .ParseIP ("10.0.16.1" )
63
- Expect (err ).NotTo (HaveOccurred ())
64
- Expect (ip .String ()).To (Equal ("10.0.16.1" ))
60
+ Describe ("String" , func () {
61
+ It ("returns a string representation of IP object" , func () {
62
+ ip , err := bosh .ParseIP ("10.0.16.1" )
63
+ Expect (err ).NotTo (HaveOccurred ())
64
+ Expect (ip .String ()).To (Equal ("10.0.16.1" ))
65
+ })
65
66
})
66
67
})
67
- })
68
68
Context ("v6" , func () {
69
69
Describe ("ParseIP" , func () {
70
70
It ("returns an IP object that represents IP from string" , func () {
71
- ip , err := bosh .ParseIP ("2001:db8:cf:0:0:ffff:1337" )
71
+ ip , err := bosh .ParseIP ("2001:db8:cf:0:0:0: ffff:1337" )
72
72
Expect (err ).NotTo (HaveOccurred ())
73
73
Expect (ip .String ()).To (Equal ("2001:db8:cf::ffff:1337" ))
74
74
})
75
75
76
76
Context ("failure cases" , func () {
77
77
It ("returns an error if it cannot parse ip" , func () {
78
78
_ , err := bosh .ParseIP ("2001:db8:cf::not valid" )
79
- Expect (err ).To (MatchError (ContainSubstring ("unable to parse IP " )))
79
+ Expect (err ).To (MatchError (ContainSubstring ("each colon-separated field must have at least one digit " )))
80
80
})
81
81
82
82
It ("returns an error if ip parts are not digits" , func () {
83
83
_ , err := bosh .ParseIP ("2001:db8:cf:x:x:x:x" )
84
- Expect (err ).To (MatchError (ContainSubstring ("unexpected character " )))
84
+ Expect (err ).To (MatchError (ContainSubstring ("each colon-separated field must have at least one digit " )))
85
85
})
86
86
87
87
It ("returns an error if ip parts are out of the allowed range" , func () {
88
88
_ , err := bosh .ParseIP ("2001:db8:cf:G::" )
89
- Expect (err ).To (MatchError (ContainSubstring ("IPv6 field has value >F " )))
89
+ Expect (err ).To (MatchError (ContainSubstring ("each colon-separated field must have at least one digit " )))
90
90
})
91
91
92
92
It ("returns an error if ip has too many parts" , func () {
93
93
_ , err := bosh .ParseIP ("2001:db8:cf:0:0:0:ffff:ffff:ffff" )
94
- Expect (err ).To (MatchError (ContainSubstring ("IPv6 address too long " )))
94
+ Expect (err ).To (MatchError (ContainSubstring ("trailing garbage after address " )))
95
95
})
96
96
})
97
97
})
0 commit comments