| ... | @@ -136,21 +136,22 @@ test "resolve DNS" { | ... | @@ -136,21 +136,22 @@ test "resolve DNS" { |
| 136 | }; | 136 | }; |
| 137 | | 137 | |
| 138 | var addresses_found: usize = 0; | 138 | var addresses_found: usize = 0; |
| | 139 | var found_canonical_name = false; |
| 139 | | 140 | |
| 140 | while (results.getOne(io)) |result| switch (result) { | 141 | while (results.getOne(io)) |result| switch (result) { |
| 141 | .address => |address| { | 142 | .address => |address| { |
| 142 | if (address.eql(&localhost_v4) or address.eql(&localhost_v6)) | 143 | if (address.eql(&localhost_v4) or address.eql(&localhost_v6)) |
| 143 | addresses_found += 1; | 144 | addresses_found += 1; |
| 144 | }, | 145 | }, |
| 145 | .canonical_name => |canonical_name| try testing.expectEqualStrings( | 146 | // We can't test the actual string here because it might be "localhost.localdomain" |
| 146 | if (canonical_name.bytes[canonical_name.bytes.len - 1] == '.') "localhost." else "localhost", | 147 | // or even the computer host name (as on Windows). |
| 147 | canonical_name.bytes, | 148 | .canonical_name => found_canonical_name = true, |
| 148 | ), | | |
| 149 | } else |err| switch (err) { | 149 | } else |err| switch (err) { |
| 150 | error.Closed => {}, | 150 | error.Closed => {}, |
| 151 | error.Canceled => |e| return e, | 151 | error.Canceled => |e| return e, |
| 152 | } | 152 | } |
| 153 | | 153 | |
| | 154 | try testing.expect(found_canonical_name); |
| 154 | try testing.expect(addresses_found != 0); | 155 | try testing.expect(addresses_found != 0); |
| 155 | } | 156 | } |
| 156 | | 157 | |