File: open_test.go

package info (click to toggle)
golang-github-skratchdot-open-golang 0.0~git20160302.0.75fb7ed-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 128 kB
  • sloc: sh: 380; makefile: 7
file content (70 lines) | stat: -rw-r--r-- 1,575 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package open

import "testing"

func TestRun(t *testing.T) {
	// shouldn't error
	input := "https://google.com/"
	err := Run(input)
	if err != nil {
		t.Errorf("open.Run(\"%s\") threw an error: %s", input, err)
	}

	// should error
	input = "xxxxxxxxxxxxxxx"
	err = Run(input)
	if err == nil {
		t.Errorf("Run(\"%s\") did not throw an error as expected", input)
	}
}

func TestStart(t *testing.T) {
	// shouldn't error
	input := "https://google.com/"
	err := Start(input)
	if err != nil {
		t.Errorf("open.Start(\"%s\") threw an error: %s", input, err)
	}

	// shouldn't error
	input = "xxxxxxxxxxxxxxx"
	err = Start(input)
	if err != nil {
		t.Errorf("open.Start(\"%s\") shouldn't even fail on invalid input: %s", input, err)
	}
}

func TestRunWith(t *testing.T) {
	// shouldn't error
	input := "https://google.com/"
	app := "firefox"
	err := RunWith(input, app)
	if err != nil {
		t.Errorf("open.RunWith(\"%s\", \"%s\") threw an error: %s", input, app, err)
	}

	// should error
	app = "xxxxxxxxxxxxxxx"
	err = RunWith(input, app)
	if err == nil {
		t.Errorf("RunWith(\"%s\", \"%s\") did not throw an error as expected", input, app)
	}
}

func TestStartWith(t *testing.T) {
	// shouldn't error
	input := "https://google.com/"
	app := "firefox"
	err := StartWith(input, app)
	if err != nil {
		t.Errorf("open.StartWith(\"%s\", \"%s\") threw an error: %s", input, app, err)
	}

	// shouldn't error
	input = "[<Invalid URL>]"
	err = StartWith(input, app)
	if err != nil {
		t.Errorf("StartWith(\"%s\", \"%s\") shouldn't even fail on invalid input: %s", input, app, err)
	}

}