File: proxy_test.go

package info (click to toggle)
golang-github-yosssi-ace-proxy 0.0~git20141007.0.ecd9b78-5.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 80 kB
  • sloc: makefile: 3
file content (45 lines) | stat: -rw-r--r-- 832 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
package proxy

import (
	"testing"

	"github.com/yosssi/ace"
)

func TestNew(t *testing.T) {
	p := New(nil)

	if p.Opts != nil {
		t.Errorf("the options should be nil. [actual: %+v]", p.Opts)
	}
}

func TestProxy_Load_opts_not_specified(t *testing.T) {
	p := New(&ace.Options{
		BaseDir: "test",
	})

	_, err := p.Load("base", "inner", nil)

	if err != nil {
		t.Errorf("an error occurred [err: %+v]", err)
	}
}

func TestProxy_Load_opts_specified(t *testing.T) {
	p := New(&ace.Options{
		BaseDir: "test",
	})

	expectedErrMsg := "open base.ace: no such file or directory"

	_, err := p.Load("base", "inner", &ace.Options{DynamicReload: true})

	if err == nil {
		t.Error("an error should be occurred")
	}

	if err.Error() != expectedErrMsg {
		t.Errorf("the error (%s) should be occurred [actual: %+v]", expectedErrMsg, err)
	}
}