aboutsummaryrefslogtreecommitdiffstats
path: root/prog/target_test.go
blob: 4db6fdef1d0e71e9fee3d0fc98f320be1e1378e9 (plain)
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
// Copyright 2024 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package prog

import (
	"testing"

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

func TestRequiredGlobs(t *testing.T) {
	assert.Equal(t, requiredGlobs("aa/bb"), []string{"aa/bb"})
	assert.Equal(t, requiredGlobs("aa:bb"), []string{"aa", "bb"})
	assert.Equal(t, requiredGlobs("aa:bb:-cc:dd"), []string{"aa", "bb", "dd"})
}

func TestPopulateGlob(t *testing.T) {
	assert.Empty(t, populateGlob("aa", map[string][]string{
		"bb": {"c"},
	}))
	assert.Equal(t, populateGlob("aa", map[string][]string{
		"aa": {"d", "e"},
		"bb": {"c"},
	}), []string{"d", "e"})
	assert.Equal(t, populateGlob("aa:cc", map[string][]string{
		"aa": {"d", "e"},
		"bb": {"c"},
		"cc": {"f", "d"},
	}), []string{"d", "e", "f"})
	assert.Equal(t, populateGlob("aa:cc:-e", map[string][]string{
		"aa": {"d", "e"},
		"bb": {"c"},
		"cc": {"f", "d"},
	}), []string{"d", "f"})
}