It skips tests when information on current running user is unavailable.
Local IP address is retrieved by lookup of "localhost". IP addresses are
used instead of nil values.
Interface of uuid package has been changed so code using it has been
adapted.
Mock generated for stm.Interface has been updated.
Change-Id: Ide48575fa7a589c0cad00478898c2a651fda77d5
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrent", reflect.TypeOf((*MockInterface)(nil).GetCurrent))
}
+// GetCurrentRecord mocks base method
+func (m *MockInterface) GetCurrentRecord() ([]int, error) {
+ ret := m.ctrl.Call(m, "GetCurrentRecord")
+ ret0, _ := ret[0].([]int)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetCurrentRecord indicates an expected call of GetCurrentRecord
+func (mr *MockInterfaceMockRecorder) GetCurrentRecord() *gomock.Call {
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentRecord", reflect.TypeOf((*MockInterface)(nil).GetCurrentRecord))
+}
+
+// HDMI mocks base method
+func (m *MockInterface) HDMI(arg0 bool) error {
+ ret := m.ctrl.Call(m, "HDMI", arg0)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// HDMI indicates an expected call of HDMI
+func (mr *MockInterfaceMockRecorder) HDMI(arg0 interface{}) *gomock.Call {
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HDMI", reflect.TypeOf((*MockInterface)(nil).HDMI), arg0)
+}
+
// PowerTick mocks base method
func (m *MockInterface) PowerTick(arg0 time.Duration) error {
ret := m.ctrl.Call(m, "PowerTick", arg0)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrintText", reflect.TypeOf((*MockInterface)(nil).PrintText), arg0, arg1, arg2, arg3)
}
+// SetDyper mocks base method
+func (m *MockInterface) SetDyper(arg0 stm.Dyper, arg1 bool) error {
+ ret := m.ctrl.Call(m, "SetDyper", arg0, arg1)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SetDyper indicates an expected call of SetDyper
+func (mr *MockInterfaceMockRecorder) SetDyper(arg0, arg1 interface{}) *gomock.Call {
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDyper", reflect.TypeOf((*MockInterface)(nil).SetDyper), arg0, arg1)
+}
+
// SetLED mocks base method
func (m *MockInterface) SetLED(arg0 stm.LED, arg1, arg2, arg3 byte) error {
ret := m.ctrl.Call(m, "SetLED", arg0, arg1, arg2, arg3)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLED", reflect.TypeOf((*MockInterface)(nil).SetLED), arg0, arg1, arg2, arg3)
}
+// StartCurrentRecord mocks base method
+func (m *MockInterface) StartCurrentRecord(arg0 int, arg1 time.Duration) error {
+ ret := m.ctrl.Call(m, "StartCurrentRecord", arg0, arg1)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// StartCurrentRecord indicates an expected call of StartCurrentRecord
+func (mr *MockInterfaceMockRecorder) StartCurrentRecord(arg0, arg1 interface{}) *gomock.Call {
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartCurrentRecord", reflect.TypeOf((*MockInterface)(nil).StartCurrentRecord), arg0, arg1)
+}
+
+// StopCurrentRecord mocks base method
+func (m *MockInterface) StopCurrentRecord() error {
+ ret := m.ctrl.Call(m, "StopCurrentRecord")
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// StopCurrentRecord indicates an expected call of StopCurrentRecord
+func (mr *MockInterfaceMockRecorder) StopCurrentRecord() *gomock.Call {
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StopCurrentRecord", reflect.TypeOf((*MockInterface)(nil).StopCurrentRecord))
+}
+
// TS mocks base method
func (m *MockInterface) TS() error {
ret := m.ctrl.Call(m, "TS")
It("should prepare", func() {
u, err := user.Current()
- Expect(err).ToNot(HaveOccurred())
+ if err != nil {
+ Skip("failed to get user info")
+ }
if u.Uid != "0" {
Skip("must be run as root")
}
}
u, err := user.Current()
- Expect(err).ToNot(HaveOccurred())
+ if err != nil {
+ Skip("failed to get user info")
+ }
if u.Uid != "0" {
Skip("must be run as root")
}
var _ = Describe("Tunnels", func() {
invalidIP := net.IPv4(255, 8, 8, 8)
+ var localIP net.IP
- listen := func(done chan struct{}, in, out string) *net.TCPAddr {
+ listen := func(done chan struct{}, in, out string) net.TCPAddr {
addr := new(net.TCPAddr)
+ addr.IP = localIP
ln, err := net.ListenTCP("tcp", addr)
go func() {
defer close(done)
}
}()
Expect(err).ToNot(HaveOccurred())
- return ln.Addr().(*net.TCPAddr)
+ return *ln.Addr().(*net.TCPAddr)
}
var t *Tunnel
BeforeEach(func() {
+ IPs, err := net.LookupIP("localhost")
+ Expect(err).ToNot(HaveOccurred())
+ if len(IPs) == 0 {
+ Skip("Could not resolve localhost")
+ }
+ localIP = IPs[0]
+
t = new(Tunnel)
Expect(t).NotTo(BeNil())
})
It("should make a connection", func() {
done := make(chan struct{})
lAddr := listen(done, "", "")
- err := t.create(nil, nil, lAddr.Port)
+ err := t.create(localIP, localIP, lAddr.Port)
Expect(err).ToNot(HaveOccurred())
- conn, err := net.DialTCP("tcp", nil, lAddr)
+ lAddr.IP = localIP
+ conn, err := net.DialTCP("tcp", nil, &lAddr)
Expect(err).ToNot(HaveOccurred())
defer conn.Close()
testIn := "input test string"
testOut := "output test string"
lAddr := listen(done, testIn, testOut)
- err := t.create(nil, nil, lAddr.Port)
+ err := t.create(localIP, localIP, lAddr.Port)
Expect(err).ToNot(HaveOccurred())
conn, err := net.DialTCP("tcp", nil, t.Addr().(*net.TCPAddr))
Expect(err).ToNot(HaveOccurred())
})
It("should fail to connect to invalid address", func() {
- err := t.create(nil, nil, 0)
+ err := t.create(localIP, localIP, 0)
Expect(err).ToNot(HaveOccurred())
conn, err := net.DialTCP("tcp", nil, t.Addr().(*net.TCPAddr))
}
})
+ getUUID := func() string {
+ u, err := uuid.NewV4()
+ Expect(err).ToNot(HaveOccurred())
+ return u.String()
+ }
+
Describe("Register", func() {
var registeredWorkers []string
getRandomCaps := func() Capabilities {
return Capabilities{
- UUID: uuid.NewV4().String(),
+ UUID: getUUID(),
}
}
randomUUID := func() WorkerUUID {
newUUID := worker
for newUUID == worker {
- newUUID = WorkerUUID(uuid.NewV4().String())
+ newUUID = WorkerUUID(getUUID())
}
return newUUID
}
registerWorker := func() WorkerUUID {
- capsUUID := uuid.NewV4().String()
+ capsUUID := getUUID()
err := wl.Register(Capabilities{UUID: capsUUID})
Expect(err).ToNot(HaveOccurred())
wl.mutex.RLock()
var refWorkerList []WorkerInfo
registerAndSetGroups := func(groups Groups, caps Capabilities) WorkerInfo {
- capsUUID := uuid.NewV4().String()
+ capsUUID := getUUID()
caps[UUID] = capsUUID
err := wl.Register(caps)
Expect(err).ToNot(HaveOccurred())
})
Describe("TakeBestMatchingWorker", func() {
addWorker := func(groups Groups, caps Capabilities) *mapWorker {
- capsUUID := uuid.NewV4().String()
+ capsUUID := getUUID()
workerUUID := WorkerUUID(capsUUID)
caps[UUID] = capsUUID
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
wl = workers.NewWorkerList()
})
+ getUUID := func() string {
+ u, err := uuid.NewV4()
+ Expect(err).ToNot(HaveOccurred())
+ return u.String()
+ }
+
getRandomCaps := func() boruta.Capabilities {
return map[string]string{
- workers.UUID: uuid.NewV4().String(),
+ workers.UUID: getUUID(),
}
}