This file is indexed.

/usr/share/gocode/src/github.com/aanand/compose-file/interpolation/interpolation_test.go is in golang-github-aanand-compose-file-dev 0.0~git20161122.0.a3e5876-1.

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 interpolation

import (
	"testing"

	"github.com/stretchr/testify/assert"

	"github.com/aanand/compose-file/types"
)

var defaults = map[string]string{
	"USER": "jenny",
	"FOO":  "bar",
}

func defaultMapping(name string) (string, bool) {
	val, ok := defaults[name]
	return val, ok
}

func TestInterpolate(t *testing.T) {
	services := types.Dict{
		"servicea": types.Dict{
			"image":   "example:${USER}",
			"volumes": []interface{}{"$FOO:/target"},
			"logging": types.Dict{
				"driver": "${FOO}",
				"options": types.Dict{
					"user": "$USER",
				},
			},
		},
	}
	expected := types.Dict{
		"servicea": types.Dict{
			"image":   "example:jenny",
			"volumes": []interface{}{"bar:/target"},
			"logging": types.Dict{
				"driver": "bar",
				"options": types.Dict{
					"user": "jenny",
				},
			},
		},
	}
	result, err := Interpolate(services, "service", defaultMapping)
	assert.NoError(t, err)
	assert.Equal(t, expected, result)
}

func TestInvalidInterpolation(t *testing.T) {
	services := types.Dict{
		"servicea": types.Dict{
			"image": "${",
		},
	}
	_, err := Interpolate(services, "service", defaultMapping)
	assert.EqualError(t, err, `Invalid interpolation format for "image" option in service "servicea": "${"`)
}