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