summaryrefslogtreecommitdiffstats
path: root/client/go/script-utils/startcbinary/progspec_test.go
blob: 8a38fb8777b3c471d92f103d575db5bea88cb4fa (plain) (blame)
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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package startcbinary

import (
	"testing"

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

func TestProgSpec(t *testing.T) {
	var spec ProgSpec
	spec.Program = "/opt/vespa/bin/foobar"
	spec.setup()
	var b bool

	b = spec.matchesListString("")
	assert.Equal(t, false, b)
	b = spec.matchesListString("foobar")
	assert.Equal(t, true, b)
	b = spec.matchesListString("foo bar")
	assert.Equal(t, false, b)
	b = spec.matchesListString("one foobar")
	assert.Equal(t, true, b)
	b = spec.matchesListString("foobar two")
	assert.Equal(t, true, b)
	b = spec.matchesListString("one foobar two")
	assert.Equal(t, true, b)
	b = spec.matchesListString("all")
	assert.Equal(t, true, b)

	var s string
	s = spec.valueFromListString("")
	assert.Equal(t, "", s)
	s = spec.valueFromListString("foobar=123")
	assert.Equal(t, "123", s)
	s = spec.valueFromListString("one=1 foobar=123 two=2")
	assert.Equal(t, "123", s)
	s = spec.valueFromListString("one=1 all=123")
	assert.Equal(t, "123", s)
}