File: mock_test.go

package info (click to toggle)
golang-github-samalba-dockerclient 0.0~git20160531.0.a303626-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 208 kB
  • sloc: makefile: 5
file content (32 lines) | stat: -rw-r--r-- 599 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
package mockclient

import (
	"reflect"
	"testing"

	"github.com/samalba/dockerclient"
)

func TestMock(t *testing.T) {
	mock := NewMockClient()
	mock.On("Version").Return(&dockerclient.Version{Version: "foo"}, nil).Once()

	v, err := mock.Version()
	if err != nil {
		t.Fatal(err)
	}
	if v.Version != "foo" {
		t.Fatal(v)
	}

	mock.Mock.AssertExpectations(t)
}

func TestMockInterface(t *testing.T) {
	iface := reflect.TypeOf((*dockerclient.Client)(nil)).Elem()
	mock := NewMockClient()

	if !reflect.TypeOf(mock).Implements(iface) {
		t.Fatalf("Mock does not implement the Client interface")
	}
}