forked from thanos-io/thanos
-
Notifications
You must be signed in to change notification settings - Fork 15
/
tools_test.go
47 lines (36 loc) · 1.2 KB
/
tools_test.go
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
// Copyright (c) The Thanos Authors.
// Licensed under the Apache License 2.0.
package main
import (
"testing"
"github.com/go-kit/log"
"github.com/efficientgo/core/testutil"
)
func Test_CheckRules(t *testing.T) {
validFiles := []string{
"./testdata/rules-files/valid.yaml",
}
invalidFiles := [][]string{
{"./testdata/rules-files/non-existing-file.yaml"},
{"./testdata/rules-files/invalid-yaml-format.yaml"},
{"./testdata/rules-files/invalid-rules-data.yaml"},
{"./testdata/rules-files/invalid-unknown-field.yaml"},
}
logger := log.NewNopLogger()
testutil.Ok(t, checkRulesFiles(logger, &validFiles))
for _, fn := range invalidFiles {
testutil.NotOk(t, checkRulesFiles(logger, &fn), "expected err for file %s", fn)
}
}
func Test_CheckRules_Glob(t *testing.T) {
// regex path
files := &[]string{"./testdata/rules-files/valid*.yaml"}
logger := log.NewNopLogger()
testutil.Ok(t, checkRulesFiles(logger, files))
// direct path
files = &[]string{"./testdata/rules-files/valid.yaml"}
testutil.Ok(t, checkRulesFiles(logger, files))
// invalid path
files = &[]string{"./testdata/rules-files/*.yamlaaa"}
testutil.NotOk(t, checkRulesFiles(logger, files), "expected err for file %s", files)
}