Debian Codegraph @

sls/logtail_test.go

raw symbols SCIP
1 package sls
2
3 import (
4 "testing"
5 )
6
7 func TestLogtailConfigs(t *testing.T) {
8 p := DefaultProject(t)
9 _, err := p.ListConfig(0, 100)
10 if err != nil {
11 t.Fatalf("error list logtail configs: %v", err)
12 }
13 }
14
15 func TestCreateLogtailConfig(t *testing.T) {
16 p := DefaultProject(t)
17 name := "logtail-test"
18 logtailConfig := &LogtailConfig{
19 Name: name,
20 InputType: "file",
21 InputDetail: LogtailInput{
22 LogType: "common_reg_log",
23 LogPath: "/abc",
24 FilePattern: "*.log",
25 LocalStorage: false,
26 TimeFormat: "",
27 LogBeginRegex: ".*",
28 Regex: "(.*)",
29 Key: []string{"content"},
30 FilterKey: []string{"content"},
31 FilterRegex: []string{".*"},
32 TopicFormat: "none",
33 },
34 OutputType: "LogService",
35 Sample: "sample",
36 OutputDetail: LogtailOutput{
37 LogstoreName: TestLogstoreName,
38 },
39 }
40
41 _, err := p.GetConfig(logtailConfig.Name)
42 if err != nil {
43 if e, ok := err.(*Error); ok && e.Code == "ConfigNotExist" {
44 if err := p.CreateConfig(logtailConfig); err != nil {
45 t.Fatalf("error create logtail config: %v", err)
46 }
47 } else {
48 t.Fatalf("Get config error: %v", err)
49 }
50 }
51
52 if err := p.DeleteConfig(name); err != nil {
53 t.Fatalf("error delete logtail config: %v", err)
54 }
55 }