This file is indexed.

/usr/share/gocode/src/github.com/mesos/mesos-go/detector/factory_test.go is in golang-github-mesos-mesos-go-dev 0.0.2+dfsg-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
package detector

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

type testDetector string

func (d testDetector) Start() error                 { return nil }
func (d testDetector) Detect(f MasterChanged) error { return nil }

func (d testDetector) Done() <-chan struct{} { return make(<-chan struct{}) }
func (d testDetector) Cancel()               {}

// unregister a factory plugin according to its prefix.
// this is part of the testing module on purpose: during normal execution there
// should be no need to dynamically unregister plugins.
func Unregister(prefix string) {
	pluginLock.Lock()
	defer pluginLock.Unlock()
	delete(plugins, prefix)
}

func TestDetectorFactoryRegister(t *testing.T) {
	prefix := "bbm:"
	Register(prefix, func(spec string) (Master, error) {
		return testDetector("Hello!"), nil
	})
	defer Unregister(prefix)

	f, ok := MatchingPlugin(prefix)

	assert.True(t, ok)
	assert.NotNil(t, f)
}

func TestDectorFactoryNew_EmptySpec(t *testing.T) {
	assert := assert.New(t)
	m, err := New("")
	assert.NotNil(err)
	assert.Nil(m)
}

func TestDectorFactoryNew_InvalidSpec(t *testing.T) {
	assert := assert.New(t)
	m, err := New("localhost")
	assert.NotNil(err)
	assert.Nil(m)
}

func TestDectorFactoryNew_TrivialSpec(t *testing.T) {
	assert := assert.New(t)
	m, err := New("localhost:1")
	assert.NoError(err)
	assert.NotNil(m)
	assert.IsType(&Standalone{}, m)
}