This file is indexed.

/usr/share/gocode/src/github.com/alicebob/miniredis/keys_test.go is in golang-github-alicebob-miniredis-dev 2.2.1-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
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package miniredis

import (
	"testing"
)

func TestKeysSel(t *testing.T) {
	// Helper to test the selection behind KEYS
	// pattern -> cases -> should match?
	for pat, chk := range map[string]map[string]bool{
		"aap": {
			"aap":         true,
			"aapnoot":     false,
			"nootaap":     false,
			"nootaapnoot": false,
			"AAP":         false,
		},
		"aap*": {
			"aap":         true,
			"aapnoot":     true,
			"nootaap":     false,
			"nootaapnoot": false,
			"AAP":         false,
		},
		// No problem with regexp meta chars?
		"(?:a)ap*": {
			"(?:a)ap!": true,
			"aap":      false,
		},
		"*aap*": {
			"aap":         true,
			"aapnoot":     true,
			"nootaap":     true,
			"nootaapnoot": true,
			"AAP":         false,
			"a_a_p":       false,
		},
		`\*aap*`: {
			"*aap":     true,
			"aap":      false,
			"*aapnoot": true,
			"aapnoot":  false,
		},
		`aa?`: {
			"aap":  true,
			"aal":  true,
			"aaf":  true,
			"aa?":  true,
			"aap!": false,
		},
		`aa\?`: {
			"aap":  false,
			"aa?":  true,
			"aa?!": false,
		},
		"aa[pl]": {
			"aap":  true,
			"aal":  true,
			"aaf":  false,
			"aa?":  false,
			"aap!": false,
		},
		"[ab]a[pl]": {
			"aap":  true,
			"aal":  true,
			"bap":  true,
			"bal":  true,
			"aaf":  false,
			"cap":  false,
			"aa?":  false,
			"aap!": false,
		},
		`\[ab\]`: {
			"[ab]": true,
			"a":    false,
		},
		`[\[ab]`: {
			"[": true,
			"a": true,
			"b": true,
			"c": false,
			"]": false,
		},
		`[\[\]]`: {
			"[": true,
			"]": true,
			"c": false,
		},
		`\\ap`: {
			`\ap`:  true,
			`\\ap`: false,
		},
		// Escape a normal char
		`\foo`: {
			`foo`:  true,
			`\foo`: false,
		},
	} {
		patRe := patternRE(pat)
		if patRe == nil {
			t.Errorf("'%v' won't match anything. Didn't expect that.\n", pat)
			continue
		}
		for key, expected := range chk {
			match := patRe.MatchString(key)
			if expected != match {
				t.Errorf("'%v' -> '%v'. Matches %v, should %v\n", pat, key, match, expected)
			}
		}
	}

	// Patterns which won't match anything.
	for _, pat := range []string{
		`ap[\`, // trailing \ in char class
		`ap[`,  // open char class
		`[]ap`, // empty char class
		`ap\`,  // trailing \
	} {
		if patternRE(pat) != nil {
			t.Errorf("'%v' will match something. Didn't expect that.\n", pat)
		}
	}
}