| 1 |
package open |
| 2 |
|
| 3 |
import "testing" |
| 4 |
|
| 5 |
func TestRun(t *testing.T) { |
| 6 |
|
| 7 |
input := "https://google.com/" |
| 8 |
err := Run(input) |
| 9 |
if err != nil { |
| 10 |
t.Errorf("open.Run(\"%s\") threw an error: %s", input, err) |
| 11 |
} |
| 12 |
|
| 13 |
|
| 14 |
input = "xxxxxxxxxxxxxxx" |
| 15 |
err = Run(input) |
| 16 |
if err == nil { |
| 17 |
t.Errorf("Run(\"%s\") did not throw an error as expected", input) |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
func TestStart(t *testing.T) { |
| 22 |
|
| 23 |
input := "https://google.com/" |
| 24 |
err := Start(input) |
| 25 |
if err != nil { |
| 26 |
t.Errorf("open.Start(\"%s\") threw an error: %s", input, err) |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
input = "xxxxxxxxxxxxxxx" |
| 31 |
err = Start(input) |
| 32 |
if err != nil { |
| 33 |
t.Errorf("open.Start(\"%s\") shouldn't even fail on invalid input: %s", input, err) |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
func TestRunWith(t *testing.T) { |
| 38 |
|
| 39 |
input := "https://google.com/" |
| 40 |
app := "firefox" |
| 41 |
err := RunWith(input, app) |
| 42 |
if err != nil { |
| 43 |
t.Errorf("open.RunWith(\"%s\", \"%s\") threw an error: %s", input, app, err) |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
app = "xxxxxxxxxxxxxxx" |
| 48 |
err = RunWith(input, app) |
| 49 |
if err == nil { |
| 50 |
t.Errorf("RunWith(\"%s\", \"%s\") did not throw an error as expected", input, app) |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
func TestStartWith(t *testing.T) { |
| 55 |
|
| 56 |
input := "https://google.com/" |
| 57 |
app := "firefox" |
| 58 |
err := StartWith(input, app) |
| 59 |
if err != nil { |
| 60 |
t.Errorf("open.StartWith(\"%s\", \"%s\") threw an error: %s", input, app, err) |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
input = "[<Invalid URL>]" |
| 65 |
err = StartWith(input, app) |
| 66 |
if err != nil { |
| 67 |
t.Errorf("StartWith(\"%s\", \"%s\") shouldn't even fail on invalid input: %s", input, app, err) |
| 68 |
} |
| 69 |
|
| 70 |
} |