OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package lhttp | 5 package lhttp |
6 | 6 |
7 import ( | 7 import ( |
8 "errors" | 8 "errors" |
9 "testing" | 9 "testing" |
10 | 10 |
11 "github.com/maruel/ut" | 11 "github.com/maruel/ut" |
12 ) | 12 ) |
13 | 13 |
14 func TestURLToHTTPS(t *testing.T) { | 14 func TestURLToHTTPS(t *testing.T) { |
15 data := []struct { | 15 data := []struct { |
16 in string | 16 in string |
17 expected string | 17 expected string |
18 err error | 18 err error |
19 }{ | 19 }{ |
20 {"foo", "https://foo", nil}, | 20 {"foo", "https://foo", nil}, |
21 {"https://foo", "https://foo", nil}, | 21 {"https://foo", "https://foo", nil}, |
22 {"http://foo", "", errors.New("Only https:// scheme is accepted.
It can be omitted.")}, | 22 {"http://foo", "", errors.New("Only https:// scheme is accepted.
It can be omitted.")}, |
23 } | 23 } |
24 for i, line := range data { | 24 for i, line := range data { |
25 out, err := URLToHTTPS(line.in) | 25 out, err := URLToHTTPS(line.in) |
26 ut.AssertEqualIndex(t, i, line.expected, out) | 26 ut.AssertEqualIndex(t, i, line.expected, out) |
27 ut.AssertEqualIndex(t, i, line.err, err) | 27 ut.AssertEqualIndex(t, i, line.err, err) |
28 } | 28 } |
29 } | 29 } |
OLD | NEW |