File: server_wrapper.go

package info (click to toggle)
consul 1.8.7%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, bullseye-backports
  • size: 57,848 kB
  • sloc: javascript: 25,918; sh: 3,807; makefile: 135; cpp: 102
file content (65 lines) | stat: -rw-r--r-- 1,623 bytes parent folder | download | duplicates (2)
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
package testutil

import "testing"

type WrappedServer struct {
	s *TestServer
	t *testing.T
}

// Wrap wraps the test server in a `testing.t` for convenience.
//
// For example, the following code snippets are equivalent.
//
//   server.JoinLAN(t, "1.2.3.4")
//   server.Wrap(t).JoinLAN("1.2.3.4")
//
// This is useful when you are calling multiple functions and save the wrapped
// value as another variable to reduce the inclusion of "t".
func (s *TestServer) Wrap(t *testing.T) *WrappedServer {
	return &WrappedServer{s, t}
}

func (w *WrappedServer) JoinLAN(addr string) {
	w.s.JoinLAN(w.t, addr)
}

func (w *WrappedServer) JoinWAN(addr string) {
	w.s.JoinWAN(w.t, addr)
}

func (w *WrappedServer) SetKV(key string, val []byte) {
	w.s.SetKV(w.t, key, val)
}

func (w *WrappedServer) SetKVString(key string, val string) {
	w.s.SetKVString(w.t, key, val)
}

func (w *WrappedServer) GetKV(key string) []byte {
	return w.s.GetKV(w.t, key)
}

func (w *WrappedServer) GetKVString(key string) string {
	return w.s.GetKVString(w.t, key)
}

func (w *WrappedServer) PopulateKV(data map[string][]byte) {
	w.s.PopulateKV(w.t, data)
}

func (w *WrappedServer) ListKV(prefix string) []string {
	return w.s.ListKV(w.t, prefix)
}

func (w *WrappedServer) AddService(name, status string, tags []string) {
	w.s.AddService(w.t, name, status, tags)
}

func (w *WrappedServer) AddAddressableService(name, status, address string, port int, tags []string) {
	w.s.AddAddressableService(w.t, name, status, address, port, tags)
}

func (w *WrappedServer) AddCheck(name, serviceID, status string) {
	w.s.AddCheck(w.t, name, serviceID, status)
}